From e25d3f2a67f3fc5e35c27e0993eb0ae9bfaffecf Mon Sep 17 00:00:00 2001 From: zhou <123@> Date: Mon, 24 Mar 2025 19:24:30 +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 | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/yuthon_salary/models/inherit_hr_payslip.py b/yuthon_salary/models/inherit_hr_payslip.py index cbaef2175..feb17a1bb 100644 --- a/yuthon_salary/models/inherit_hr_payslip.py +++ b/yuthon_salary/models/inherit_hr_payslip.py @@ -1,5 +1,5 @@ from odoo import api, fields, models, _ - +from odoo.exceptions import ValidationError, UserError class InheritHrPayslip(models.Model): _inherit = 'hr.payslip' @@ -223,19 +223,18 @@ class InheritHrPayslip(models.Model): "target": "new", } - def compute_sheet(self, custom_date): + def compute_sheet(self): payslips = self.filtered(lambda slip: slip.state in ['draft', 'verify']) # delete old payslip lines payslips.line_ids.unlink() # this guarantees consistent results self.env.flush_all() - today = custom_date if custom_date else fields.Date.today() for payslip in payslips: number = payslip.number or self.env['ir.sequence'].next_by_code('salary.slip') payslip.write({ 'number': number, 'state': 'verify', - 'compute_date': today + 'compute_date': '2025-01-01' }) self.env['hr.payslip.line'].create(payslips._get_payslip_lines()) - return True \ No newline at end of file + return True