Merge pull request !9321 from 李鹏宇/dev_wang
This commit is contained in:
李鹏宇
2026-03-05 13:54:12 +00:00
committed by Gitee
2 changed files with 47 additions and 0 deletions
@@ -48,6 +48,11 @@ class YuthonVacationReports(models.Model):
late_allowed = fields.Float(related="employee_id.late_allowed", string="允许迟到次数")
leave_ids = fields.One2many('vacation.leave.line', 'vacation_id', string='年假明细')
overtime_ids = fields.One2many('vacation.over.line', 'vacation_id', string='加班明细')
# 加班明细合计字段
overtime_workday_total = fields.Float(string='工作日合计', compute='_compute_overtime_totals', digits=(16, 1))
overtime_legal_day_total = fields.Float(string='法定节假日合计', compute='_compute_overtime_totals', digits=(16, 1))
overtime_public_holidays_total = fields.Float(string='公休日合计', compute='_compute_overtime_totals', digits=(16, 1))
overtime_grand_total = fields.Float(string='总合计', compute='_compute_overtime_totals', digits=(16, 1))
meal_fee_ids = fields.One2many('vacation.meal.line', 'vacation_id', string='误餐明细')
medical_fee_ids = fields.One2many('vacation.medical.line', 'vacation_id', string='体检费明细')
parenting_line_ids = fields.One2many('vacation.parenting.line', 'vacation_id', string='育儿假明细')
@@ -1406,6 +1411,34 @@ class YuthonVacationReports(models.Model):
record.statutory_leave = legal_total/8
record.cop_leave = total_add2 / 8
@api.depends('overtime_ids.workday', 'overtime_ids.legal_day', 'overtime_ids.public_holidays', 'overtime_ids.update_type', 'overtime_ids.is_void')
def _compute_overtime_totals(self):
"""计算加班明细的合计:工作日、法定节假日、公休日的合计,以及总合计
根据update_type判断是增加还是减少
"""
for record in self:
workday_total = 0.0
legal_day_total = 0.0
public_holidays_total = 0.0
for line in record.overtime_ids:
if line.is_void:
continue
if line.update_type == 'add':
workday_total += line.workday or 0
legal_day_total += line.legal_day or 0
public_holidays_total += line.public_holidays or 0
elif line.update_type == 'reduce':
workday_total -= line.workday or 0
legal_day_total -= line.legal_day or 0
public_holidays_total -= line.public_holidays or 0
record.overtime_workday_total = workday_total
record.overtime_legal_day_total = legal_day_total
record.overtime_public_holidays_total = public_holidays_total
record.overtime_grand_total = workday_total + legal_day_total + public_holidays_total
@api.depends('meal_fee_ids.update_lines', 'meal_fee_ids.update_type', 'meal_fee_ids.is_void')
def _compute_meal_fee(self):
for record in self:
@@ -250,6 +250,20 @@
</page>
<page string="加班">
<button name="overtime_allocation" string="分配" type="object" class="btn btn-primary"/>
<group col="4">
<group>
<field name="overtime_workday_total" readonly="1"/>
</group>
<group>
<field name="overtime_legal_day_total" readonly="1"/>
</group>
<group>
<field name="overtime_public_holidays_total" readonly="1"/>
</group>
<group>
<field name="overtime_grand_total" readonly="1"/>
</group>
</group>
<field name="overtime_ids" context="{'default_employee_id': employee_id}">
<tree editable="bottom" delete="false" decoration-muted="is_void" decoration-danger="update_type == 'reduce'">
<button name="open_record" type="object" string="详情" class="btn-primary"