From 0029e2055fe8b46e64661b7923ba5e54052227ed Mon Sep 17 00:00:00 2001 From: zhou <123@> Date: Mon, 12 May 2025 18:01:41 +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 | 2 +- yuthon_salary/wizard/salary_payslip_wizard.py | 16 ++++++++++++---- .../views/yuthon_will_task_views.xml | 10 ++++++++++ 3 files changed, 23 insertions(+), 5 deletions(-) diff --git a/yuthon_salary/models/inherit_hr_payslip.py b/yuthon_salary/models/inherit_hr_payslip.py index 5e66de661..a923bbbb4 100644 --- a/yuthon_salary/models/inherit_hr_payslip.py +++ b/yuthon_salary/models/inherit_hr_payslip.py @@ -68,7 +68,7 @@ class InheritHrPayslip(models.Model): salary_state = fields.Selection([('to_signed', '待签字' ), ('to_release', '待发放'), ('released', '已发放')], string='状态', default='to_signed') commercial_health_insurance = fields.Float(string='商业健康保险') tax_deferred_pension_insurance = fields.Float(string='税延养老保险') - others = fields.Float(string='其他') + others = fields.Float(string='其他扣除') deductible_donations = fields.Float(string='准予扣除的捐赠额') total_pre_tax_deductions = fields.Float(string='税前扣除项目合计') tax_reduction = fields.Float(string='减免税额') diff --git a/yuthon_salary/wizard/salary_payslip_wizard.py b/yuthon_salary/wizard/salary_payslip_wizard.py index f512d3ae8..c1a9f7f9f 100644 --- a/yuthon_salary/wizard/salary_payslip_wizard.py +++ b/yuthon_salary/wizard/salary_payslip_wizard.py @@ -83,9 +83,13 @@ class SalaryPayslipWizard(models.Model): current_year = datetime.now().year payslip_run_name = f'{current_year}年-{int(self.select_time)}月' month = int(self.select_time) + month_mapping = { + 1: '一月', 2: '二月', 3: '三月', 4: '四月', + 5: '五月', 6: '六月', 7: '七月', 8: '八月', + 9: '九月', 10: '十月', 11: '十一月', 12: '十二月' + } + month_name = month_mapping.get(month, '一月') payslip_run_id = self.env['hr.payslip.run'].search([('name', '=', payslip_run_name)]) - date_from = datetime(current_year, month, 1).strftime('%Y-%m-%d') - last_day = (datetime(current_year, month % 12 + 1, 1) - timedelta(days=1)).strftime('%Y-%m-%d') if not payslip_run_id: payslip_run_id = self.env['hr.payslip.run'].create({ 'name': payslip_run_name, @@ -94,8 +98,12 @@ class SalaryPayslipWizard(models.Model): 'state': 'draft', 'payslip_count': 0 }) - payslip_id = self.env['hr.payslip'].search([('employee_id', '=', employee_id.id), ('is_push', '=', True), ('is_salary_push', '=', False), - ('date_from', '>=', date_from), ('date_to', '<=', last_day)]) + payslip_id = self.env['hr.payslip'].search([ + ('employee_id', '=', employee_id.id), + ('is_push', '=', True), + ('is_salary_push', '=', False), + ('payslip_run_id.name', 'like', f'%年-{month_name}') # 匹配格式:"2025年-一月" + ]) payslip_id.write({ 'deduction_standard': row[20].value, 'specialized_deduction': row[21].value, diff --git a/yuthon_will_task/views/yuthon_will_task_views.xml b/yuthon_will_task/views/yuthon_will_task_views.xml index 10cf483e2..5d16149b2 100644 --- a/yuthon_will_task/views/yuthon_will_task_views.xml +++ b/yuthon_will_task/views/yuthon_will_task_views.xml @@ -82,6 +82,11 @@ +