This commit is contained in:
ljmwkx
2025-03-04 09:19:08 +08:00
parent 624880a1f5
commit 75c20d9886
3 changed files with 16 additions and 1 deletions
+11
View File
@@ -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()
@@ -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='人员范围')
employee_ids = fields.Many2many('hr.employee', string='人员范围')
type_of_work = fields.Selection([('0', '工作日'), ('1', '自然日')], string="工作类型", default='0')
@@ -31,6 +31,9 @@
<field name="leave_documents_id" widget="preview_many2many"/>
</group>
</xpath>
<xpath expr="//field[@name='time_type']" position="after">
<field name="type_of_work"/>
</xpath>
<xpath expr="//field[@name='requires_allocation']" position="before">
<field name="employee_ids" widget="many2many_tags"/>
</xpath>