commit
5c086aa498
|
|
@ -2861,4 +2861,10 @@ msgstr "تم التبرير "
|
||||||
#: model:ir.model.fields,field_description:attendances.field_hr_attendance_report_line__actual_absent_days
|
#: model:ir.model.fields,field_description:attendances.field_hr_attendance_report_line__actual_absent_days
|
||||||
#: model_terms:ir.ui.view,arch_db:attendances.employee_lateness_absense_overtime_form_view
|
#: model_terms:ir.ui.view,arch_db:attendances.employee_lateness_absense_overtime_form_view
|
||||||
msgid "Actual Absent Days"
|
msgid "Actual Absent Days"
|
||||||
msgstr "أيام الغياب"
|
msgstr "أيام الغياب"
|
||||||
|
|
||||||
|
#. module: attendances
|
||||||
|
#: model:ir.model.fields,field_description:attendances.field_attendance_attendance__attendance_duration
|
||||||
|
#: model:ir.model.fields,field_description:attendances.field_attendance_attendance__attendance_duration_hhmmss
|
||||||
|
msgid "Attendance Duration"
|
||||||
|
msgstr "زمن الحضور"
|
||||||
|
|
|
||||||
|
|
@ -446,6 +446,11 @@ class Attendance(models.Model):
|
||||||
|
|
||||||
is_today = fields.Boolean(string='Is Today', compute='_compute_is_today', store=True)
|
is_today = fields.Boolean(string='Is Today', compute='_compute_is_today', store=True)
|
||||||
|
|
||||||
|
attendance_duration = fields.Float(string="Attendance Duration", compute='_compute_attendance_duration',
|
||||||
|
store=True)
|
||||||
|
attendance_duration_hhmmss = fields.Char(string="Attendance Duration",
|
||||||
|
compute='_compute_attendance_duration', store=True)
|
||||||
|
|
||||||
@api.depends('action_date')
|
@api.depends('action_date')
|
||||||
def _compute_is_today(self):
|
def _compute_is_today(self):
|
||||||
today = datetime.now().date()
|
today = datetime.now().date()
|
||||||
|
|
@ -468,6 +473,43 @@ class Attendance(models.Model):
|
||||||
item.action_date = False
|
item.action_date = False
|
||||||
|
|
||||||
|
|
||||||
|
@api.depends('employee_id', 'action_date', 'action', 'name')
|
||||||
|
def _compute_attendance_duration(self):
|
||||||
|
for record in self:
|
||||||
|
record.attendance_duration = 0.0
|
||||||
|
record.attendance_duration_hhmmss = "00:00:00"
|
||||||
|
|
||||||
|
if not record.employee_id or not record.action_date:
|
||||||
|
continue
|
||||||
|
|
||||||
|
attendances = self.search([
|
||||||
|
('employee_id', '=', record.employee_id.id),
|
||||||
|
('action_date', '=', record.action_date)
|
||||||
|
], order='name ASC')
|
||||||
|
|
||||||
|
total_seconds = 0
|
||||||
|
last_sign_in = None
|
||||||
|
|
||||||
|
for att in attendances:
|
||||||
|
if att.action == 'sign_in':
|
||||||
|
if not last_sign_in:
|
||||||
|
last_sign_in = att.name
|
||||||
|
|
||||||
|
elif att.action == 'sign_out' and last_sign_in:
|
||||||
|
diff_seconds = (att.name - last_sign_in).total_seconds()
|
||||||
|
total_seconds += diff_seconds
|
||||||
|
|
||||||
|
if att.id == record.id:
|
||||||
|
hours = int(total_seconds // 3600)
|
||||||
|
minutes = int((total_seconds % 3600) // 60)
|
||||||
|
seconds = int(total_seconds % 60)
|
||||||
|
|
||||||
|
record.attendance_duration = round(total_seconds / 3600.0, 2)
|
||||||
|
record.attendance_duration_hhmmss = f"{hours:02d}:{minutes:02d}:{seconds:02d}"
|
||||||
|
|
||||||
|
last_sign_in = None
|
||||||
|
|
||||||
|
|
||||||
class HrEmployee(models.Model):
|
class HrEmployee(models.Model):
|
||||||
_inherit = 'hr.employee'
|
_inherit = 'hr.employee'
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -362,6 +362,7 @@
|
||||||
<field name="action_reason" readonly="1" force_save="1"/>
|
<field name="action_reason" readonly="1" force_save="1"/>
|
||||||
<field name="action_date" readonly="1"/>
|
<field name="action_date" readonly="1"/>
|
||||||
<field name="taken" invisible="1"/>
|
<field name="taken" invisible="1"/>
|
||||||
|
<field name="attendance_duration_hhmmss" attrs="{'invisible': [('action','!=','sign_out')]}" />
|
||||||
</group>
|
</group>
|
||||||
</sheet>
|
</sheet>
|
||||||
</form>
|
</form>
|
||||||
|
|
@ -379,6 +380,7 @@
|
||||||
<field name="name" required="1"/>
|
<field name="name" required="1"/>
|
||||||
<field name="action"/>
|
<field name="action"/>
|
||||||
<field name="action_type"/>
|
<field name="action_type"/>
|
||||||
|
<field name="attendance_duration_hhmmss" attrs="{'invisible': [('action','!=','sign_out')]}"/>
|
||||||
</tree>
|
</tree>
|
||||||
</field>
|
</field>
|
||||||
</record>
|
</record>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue