FIX CALC attendances HOLDAY
This commit is contained in:
parent
285fb022e1
commit
ba2c779b01
|
|
@ -576,9 +576,15 @@ msgstr "رقم البصمة"
|
|||
|
||||
#. module: attendances
|
||||
#: model:ir.model.fields.selection,name:attendances.selection__attendance_special_days__shift__one
|
||||
#: model:ir.model.fields.selection,name:attendances.selection__days_off__shift__one
|
||||
msgid "First Shift"
|
||||
msgstr "الشفت الاول"
|
||||
|
||||
#. module: attendances
|
||||
#: model:ir.model.fields.selection,name:attendances.selection__days_off__shift__both
|
||||
msgid "Both"
|
||||
msgstr "الشفتين معا"
|
||||
|
||||
#. module: attendances
|
||||
#: model:ir.model.fields,field_description:attendances.field_resource_calendar__number_of_flexi_days
|
||||
msgid "Flexible Days"
|
||||
|
|
@ -1242,9 +1248,11 @@ msgstr "صباح السبت"
|
|||
|
||||
#. module: attendances
|
||||
#: model:ir.model.fields.selection,name:attendances.selection__attendance_special_days__shift__two
|
||||
#: model:ir.model.fields.selection,name:attendances.selection__days_off__shift__two
|
||||
msgid "Second Shift"
|
||||
msgstr "الشفت الثاني"
|
||||
|
||||
|
||||
#. module: attendances
|
||||
#: code:addons/attendances/models/hr_attendance_register.py:0
|
||||
#: code:addons/attendances/models/hr_reasons_lateness.py:0
|
||||
|
|
|
|||
|
|
@ -330,6 +330,7 @@ class DaysOff(models.Model):
|
|||
('friday', 'Friday')], string='Day Off')
|
||||
# relation fields
|
||||
day_off_attendance = fields.Many2one('resource.calendar')
|
||||
shift = fields.Selection(selection=[('both', 'Both'),('one', 'First Shift'), ('two', 'Second Shift')],default='both',string='Shift')
|
||||
|
||||
|
||||
class SpecialDays(models.Model):
|
||||
|
|
|
|||
|
|
@ -43,6 +43,7 @@ class HrAttendanceTransactions(models.Model):
|
|||
rec.additional_hours = 0
|
||||
if rec.office_hours > rec.plan_hours:
|
||||
rec.additional_hours = rec.office_hours - rec.plan_hours
|
||||
# rec.carried_hours = rec.office_hours - rec.plan_hours
|
||||
|
||||
def get_hours(self):
|
||||
module = self.env['ir.module.module'].sudo()
|
||||
|
|
@ -62,6 +63,7 @@ class HrAttendanceTransactions(models.Model):
|
|||
item.lateness = False
|
||||
item.early_exit = False
|
||||
item.total_absent_hours = 0
|
||||
|
||||
if item.attending_type == 'out_cal' \
|
||||
or holidays_module and (item.public_holiday or item.normal_leave) \
|
||||
or official_mission_module and item.is_official and item.official_id.mission_type.duration_type == 'days':
|
||||
|
|
@ -79,11 +81,13 @@ class HrAttendanceTransactions(models.Model):
|
|||
working_hours = sum(day_trans.mapped('official_hours')) \
|
||||
+ sum(day_trans.mapped('total_mission_hours')) \
|
||||
+ sum(day_trans.mapped('total_permission_hours'))
|
||||
if working_hours < item.calendar_id.end_sign_in and not item.calendar_id.is_flexible \
|
||||
or item.calendar_id.is_flexible and working_hours == 0.0:
|
||||
day_trans.update({'is_absent': True})
|
||||
if working_hours == 0.0 and item.sign_in == 0.0 and item.sign_out == 0.0 and not item.calendar_id.is_flexible:
|
||||
day_trans.update({'is_absent': True})
|
||||
|
||||
if not item.public_holiday :
|
||||
if working_hours < item.calendar_id.end_sign_in and not item.calendar_id.is_flexible \
|
||||
or item.calendar_id.is_flexible and working_hours == 0.0:
|
||||
day_trans.filtered(lambda t: t.public_holiday == False).update({'is_absent': True})
|
||||
if working_hours == 0.0 and item.sign_in == 0.0 and item.sign_out == 0.0 and not item.calendar_id.is_flexible:
|
||||
day_trans.filtered(lambda t: t.public_holiday == False).update({'is_absent': True})
|
||||
if item.calendar_id.is_flexible:
|
||||
item.write({'temp_lateness': 0.0, 'temp_exit': 0.0, 'official_hours': item.office_hours})
|
||||
# if item.temp_lateness:
|
||||
|
|
@ -91,16 +95,19 @@ class HrAttendanceTransactions(models.Model):
|
|||
# if item.temp_exit:
|
||||
# item.approve_exit_out = True
|
||||
#################### Fix lateness,exit_out start #######################
|
||||
if item.temp_lateness or item.temp_exit: # solve one cases and add other case #TODO
|
||||
if item.temp_lateness or item.temp_exit : # solve one cases and add other case #TODO
|
||||
full_max_sign_in = item.calendar_id.full_max_sign_in
|
||||
full_min_sign_in = item.calendar_id.full_min_sign_in
|
||||
if item.calendar_id.noke:
|
||||
working_hours = item.calendar_id.working_hours
|
||||
if not item.calendar_id.is_full_day:
|
||||
if item.sequence == 1:
|
||||
full_max_sign_in = item.calendar_id.shift_one_max_sign_in
|
||||
full_min_sign_in = item.calendar_id.shift_one_min_sign_in
|
||||
working_hours = item.calendar_id.shift_one_working_hours
|
||||
if item.sequence == 2:
|
||||
full_max_sign_in = item.calendar_id.shift_two_max_sign_in
|
||||
full_min_sign_in = item.calendar_id.shift_two_min_sign_in
|
||||
working_hours = item.calendar_id.shift_two_working_hours
|
||||
|
||||
is_late_sign_in = item.sign_in > full_max_sign_in
|
||||
if item.sign_in < full_min_sign_in:
|
||||
|
|
@ -109,7 +116,7 @@ class HrAttendanceTransactions(models.Model):
|
|||
expected_sign_in = item.sign_in
|
||||
if is_late_sign_in:
|
||||
expected_sign_in = full_max_sign_in
|
||||
expected_sign_out = expected_sign_in + item.calendar_id.working_hours
|
||||
expected_sign_out = expected_sign_in + working_hours
|
||||
is_early_sign_out = item.sign_out > 0.0 and item.sign_out < expected_sign_out
|
||||
item.temp_lateness = item.sign_out > 0.0 and is_late_sign_in and item.sign_in - expected_sign_in or 0
|
||||
item.temp_exit = is_early_sign_out and expected_sign_out - item.sign_out or 0
|
||||
|
|
@ -647,7 +654,7 @@ class HrAttendanceTransactions(models.Model):
|
|||
public = self.env['hr.holiday.officials'].search([('active', '=', True), ('state', '=', 'confirm'),
|
||||
('date_from', '<=', day_item),
|
||||
('date_to', '>=', day_item)])
|
||||
employee_list = self.env['hr.employee'].search([('state', '=', 'open')]) \
|
||||
employee_list = self.env['hr.employee'].search([('state', '=', 'open'),('id','=',2949)]) \
|
||||
if not attendance_employee else attendance_employee
|
||||
|
||||
for employee in employee_list:
|
||||
|
|
@ -812,6 +819,7 @@ class HrAttendanceTransactions(models.Model):
|
|||
one_in_dom = domain.copy() + [('action', '=', 'sign_in'), ('name', '<', one_max_out_st)]
|
||||
two_in_dom = domain.copy() + [('action', '=', 'sign_in'), ('name', '>=', one_max_out_st)]
|
||||
out_dom = domain.copy() + [('action', '=', 'sign_out')]
|
||||
|
||||
signs_out = attendance_pool.search(out_dom, order="name asc")
|
||||
one_signs_in = attendance_pool.search(one_in_dom, order="name asc")
|
||||
two_signs_in = attendance_pool.search(two_in_dom, order="name asc")
|
||||
|
|
@ -951,10 +959,19 @@ class HrAttendanceTransactions(models.Model):
|
|||
off_list.append(day.name.lower())
|
||||
if day.name.lower() == day_item.strftime('%A').lower():
|
||||
for trans in day_trans:
|
||||
if emp_calendar.noke and create <= datetime.strptime(trans.date, "%Y-%m-%d").date():
|
||||
if emp_calendar.noke and create <= datetime.strptime(str(trans.date), "%Y-%m-%d").date():
|
||||
trans.update({'public_holiday': True})
|
||||
else:
|
||||
trans.update({'public_holiday': True})
|
||||
if not emp_calendar.is_full_day:
|
||||
if day.shift == 'one' and trans.sequence == 1:
|
||||
trans.update({'public_holiday': True})
|
||||
elif day.shift == 'tow' and trans.sequence == 2:
|
||||
trans.update({'public_holiday': True})
|
||||
elif day.shift == 'both' :
|
||||
trans.update({'public_holiday': True})
|
||||
else:
|
||||
trans.update({'public_holiday': True})
|
||||
|
||||
else:
|
||||
for trans in day_trans:
|
||||
if trans.public_holiday and not trans.public_holiday_id:
|
||||
|
|
|
|||
|
|
@ -226,6 +226,7 @@
|
|||
<page string="Day off">
|
||||
<field name="shift_day_off" attrs="{'readonly': [('state', '!=', 'draft')]}">
|
||||
<tree editable="bottom">
|
||||
<field name="shift" required="1"/>
|
||||
<field name="name" required="1"/>
|
||||
</tree>
|
||||
</field>
|
||||
|
|
|
|||
Loading…
Reference in New Issue