From 6ef400a9b995461abf769c8825f2221b197ea00d Mon Sep 17 00:00:00 2001 From: zhou <123@> Date: Fri, 21 Mar 2025 10:32:32 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- yuthon_salary/models/inherit_hr_payslip.py | 14 +++++++++++++- yuthon_salary/views/inherit_hr_payslip_views.xml | 3 ++- 2 files changed, 15 insertions(+), 2 deletions(-) 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 @@ -