diff --git a/yuthon_holiday/models/inherit_hr_leave.py b/yuthon_holiday/models/inherit_hr_leave.py index 1c87a8345..98b5e5ef3 100644 --- a/yuthon_holiday/models/inherit_hr_leave.py +++ b/yuthon_holiday/models/inherit_hr_leave.py @@ -111,6 +111,17 @@ class HrLeave(models.Model): ('22', '22:00'), ('22.5', '22:30'), ('23', '23:00'), ('23.5', '23:30')], string='结束时间') + @api.depends('date_from', 'date_to', 'resource_calendar_id', 'holiday_status_id.request_unit') + def _compute_duration(self): + super()._compute_duration() + for holiday in self: + # 如果是自然日: + if holiday.holiday_status_id.type_of_work == "1": + calendar = self.env['resource.calendar'].sudo().search([("name", "=", "行政考勤自然日")],limit=1) + days, hours = holiday._get_duration(resource_calendar=calendar) + holiday.number_of_hours = hours + holiday.number_of_days = days + def _compute_request_unit_hours(self): if not self.env.context.get('no_change_request_unit_hours'): super()._compute_request_unit_hours() diff --git a/yuthon_holiday/models/inherit_hr_leave_type.py b/yuthon_holiday/models/inherit_hr_leave_type.py index 1297f7fb2..ef002376b 100644 --- a/yuthon_holiday/models/inherit_hr_leave_type.py +++ b/yuthon_holiday/models/inherit_hr_leave_type.py @@ -13,4 +13,5 @@ class HrLeaveType(models.Model): start_date = fields.Date(string="生效日期", default=fields.Date.today()) expiration_date = fields.Date(string="失效日期") is_enable = fields.Boolean(string="启用", default=True) - employee_ids = fields.Many2many('hr.employee', string='人员范围') \ No newline at end of file + employee_ids = fields.Many2many('hr.employee', string='人员范围') + type_of_work = fields.Selection([('0', '工作日'), ('1', '自然日')], string="工作类型", default='0') diff --git a/yuthon_holiday/views/inherit_hr_type_views.xml b/yuthon_holiday/views/inherit_hr_type_views.xml index 9af4ef731..5de5b710f 100644 --- a/yuthon_holiday/views/inherit_hr_type_views.xml +++ b/yuthon_holiday/views/inherit_hr_type_views.xml @@ -31,6 +31,9 @@ + + +