diff --git a/yuthon_salary/models/inherit_hr_payslip.py b/yuthon_salary/models/inherit_hr_payslip.py index a26be8e5a..07d0f563d 100644 --- a/yuthon_salary/models/inherit_hr_payslip.py +++ b/yuthon_salary/models/inherit_hr_payslip.py @@ -41,7 +41,7 @@ class InheritHrPayslip(models.Model): unemployment_insurance = fields.Float(string='失业保险费', compute='_compute_salary', store=True) work_injury_insurance = fields.Float(string='工伤保险费', compute='_compute_salary', store=True) housing_provident_fund = fields.Float(string='住房公积金', compute='_compute_salary', store=True) - total_before_tax = fields.Float(string='税前合计', compute='_compute_salary', store=True) + total_before_tax = fields.Float(string='税前合计', compute='_compute_total_before_tax', store=True) attendance_deduction_total = fields.Float(string='考勤扣款合计') assessment_reserved_amount = fields.Float(string='考核保留量') @@ -132,3 +132,15 @@ class InheritHrPayslip(models.Model): "view_mode": "form", "target": "new", } + + @api.depends('line_ids') + def _compute_total_before_tax(self): + common_records = self.env['yuthon.payroll.common'].search([('before_tax', '=', True)]) + name_list = [record.name for record in common_records] + for payslip in self: + total = 0 + for line in payslip.line_ids: + if line.name in name_list: + total += line.total + payslip.total_before_tax = total + diff --git a/yuthon_salary/views/inherit_hr_payslip_views.xml b/yuthon_salary/views/inherit_hr_payslip_views.xml index 07105f056..9e9cfe172 100644 --- a/yuthon_salary/views/inherit_hr_payslip_views.xml +++ b/yuthon_salary/views/inherit_hr_payslip_views.xml @@ -32,6 +32,7 @@ + @@ -61,7 +62,6 @@ -