diff --git a/yuthon_salary/models/inherit_hr_payslip.py b/yuthon_salary/models/inherit_hr_payslip.py index 3500b3999..c892bbbd2 100644 --- a/yuthon_salary/models/inherit_hr_payslip.py +++ b/yuthon_salary/models/inherit_hr_payslip.py @@ -133,20 +133,6 @@ class InheritHrPayslip(models.Model): payslip_records = self.browse(self._context.get('active_ids', self._context.get('active_id'))) for rec in payslip_records: rec.compute_sheet() - # payslips = payslip_records or self - # payslips = payslips.filtered(lambda slip: slip.state in ['draft', 'verify'] and not slip.employee_id.contract_id.is_probation) - # payslips.line_ids.unlink() - # self.env.flush_all() - # today = 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 - # }) - # self.env['hr.payslip.line'].create(payslips._get_payslip_lines()) - # return True @api.onchange('employee_id') def _onchange_salary_group_id(self): diff --git a/yuthon_salary/wizard/salary_compute_wizard.py b/yuthon_salary/wizard/salary_compute_wizard.py index eacd95a6a..01f5a1b85 100644 --- a/yuthon_salary/wizard/salary_compute_wizard.py +++ b/yuthon_salary/wizard/salary_compute_wizard.py @@ -86,8 +86,8 @@ class SalaryComputeWizard(models.Model): ]) if existing_payslip: raise UserError(f"员工 {employee.name} 在 {start_date} 到 {end_date} 日期范围内已有工资单记录,无法创建新的工资单。") - payslip = self.env['hr.payslip'].create({ - 'is_bold':is_bold, + self.env['hr.payslip'].create({ + 'is_bold': is_bold, 'name': employee.name, 'employee_id': employee.id, 'contract_id': contract_id.id, @@ -96,8 +96,7 @@ class SalaryComputeWizard(models.Model): 'salary_group_id': employee.contract_id.salary_group_id.id, 'payslip_run_id': payslip_run_id.id, 'state': 'draft', - }) - payslip.compute_sheet() + }).compute_sheet() internship_ids = self.env['hr.payslip'].search([ ('employee_id.contract_id.is_probation', '=', True), ('date_from', '<=', end_date), @@ -186,8 +185,11 @@ class SalaryComputeWizard(models.Model): setattr(internship_id, field_name, result) line.write({'total': result}) + for rec in self.env['hr.payslip'].search([('is_push', '=', False)]): + rec.compute_sheet() - + for rec2 in self.env['hr.payslip'].search([('employee_id.name', 'in', ['黄昱皓', '谭铭浩', '朱文浩'])]): + rec2.compute_sheet() def _get_chinese_month(self, month): chinese_months = ['一月', '二月', '三月', '四月', '五月', '六月', '七月', '八月', '九月', '十月', '十一月', '十二月'] return chinese_months[month - 1]