From d09ee7eaa02821573f43dadc3f497e79066b1b1e Mon Sep 17 00:00:00 2001 From: zhou <123@> Date: Mon, 14 Jul 2025 11:51:16 +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 | 6 ++---- .../models/inherit_hr_payslip_line.py | 11 +++++----- .../models/yuthon_payroll_project.py | 2 -- yuthon_salary/wizard/salary_compute_wizard.py | 21 ++++++++++--------- 4 files changed, 19 insertions(+), 21 deletions(-) diff --git a/yuthon_salary/models/inherit_hr_payslip.py b/yuthon_salary/models/inherit_hr_payslip.py index 3dcf222bd..9491c7237 100644 --- a/yuthon_salary/models/inherit_hr_payslip.py +++ b/yuthon_salary/models/inherit_hr_payslip.py @@ -36,7 +36,7 @@ class InheritHrPayslip(models.Model): child_education = fields.Float(string='累计子女教育') tax = fields.Float(string="税金") retroactive_allowance = fields.Float(string="补发津贴") - condolence_fund = fields.Float(string="儿童节慰问金") + condolence_fund = fields.Float(string="儿童节慰问金") # 物管 continuing_education = fields.Float(string='累计继续教育') elderly_support = fields.Float(string='累计赡养老人') infant_care = fields.Float(string='累计3岁以下婴幼儿照护') @@ -63,7 +63,7 @@ class InheritHrPayslip(models.Model): total_before_tax = fields.Float(string='本期应收', compute='_compute_total_before_tax', store=True) year_compute = fields.Float(string='前年年度清算', store=True) year_jie = fields.Float(string='前年年度结余', store=True) - children_welfare_fee = fields.Float(string='六一儿童节福利') + children_welfare_fee = fields.Float(string='儿童节慰问金') # 天河 year_gong = fields.Float(string='年功奖', store=True) study_on = fields.Float(string='学习进步奖') jing_te = fields.Float(string='经营特别奖') @@ -254,8 +254,6 @@ class InheritHrPayslip(models.Model): for rec in self: if rec.line_ids: for line in rec.line_ids: - if line.name == '六一儿童节福利': - rec.children_welfare_fee = line.total if line.name == '儿童节慰问金': rec.condolence_fund = line.total if line.name == '春节福利': diff --git a/yuthon_salary/models/inherit_hr_payslip_line.py b/yuthon_salary/models/inherit_hr_payslip_line.py index 56764f9dc..244c3d742 100644 --- a/yuthon_salary/models/inherit_hr_payslip_line.py +++ b/yuthon_salary/models/inherit_hr_payslip_line.py @@ -13,8 +13,9 @@ class InheritHrPayslipLine(models.Model): @api.onchange('total') def _onchange_total(self): - if self.total and self.amount: - if self.total != self.amount: - self.is_amount = True - else: - self.is_amount = False \ No newline at end of file + for rec in self: + if rec.total: + if rec.total != rec.amount: + rec.is_amount = True + else: + rec.is_amount = False \ No newline at end of file diff --git a/yuthon_salary/models/yuthon_payroll_project.py b/yuthon_salary/models/yuthon_payroll_project.py index 8756a1999..de33d6479 100644 --- a/yuthon_salary/models/yuthon_payroll_project.py +++ b/yuthon_salary/models/yuthon_payroll_project.py @@ -91,8 +91,6 @@ class YuthonPayrollCommon(models.Model): formula_salary = "result = 0" if ins.name == '上月值班费': formula_salary = "result = 0" - if ins.name == '六一儿童节福利费': - formula_salary = "result = 0" if ins.name == '环境作业津贴': formula_salary = "result = 0" if ins.name == '儿童节慰问金': diff --git a/yuthon_salary/wizard/salary_compute_wizard.py b/yuthon_salary/wizard/salary_compute_wizard.py index 53b609ff2..590c902ce 100644 --- a/yuthon_salary/wizard/salary_compute_wizard.py +++ b/yuthon_salary/wizard/salary_compute_wizard.py @@ -2,6 +2,7 @@ from odoo import models, fields, api, _, SUPERUSER_ID from odoo.exceptions import ValidationError, UserError from odoo.exceptions import ValidationError +import calendar from pypinyin import pinyin, Style import math import xlrd @@ -33,30 +34,30 @@ class SalaryComputeWizard(models.Model): def onchange_select_year_select_time(self): year = int(self.select_year) month = int(self.select_time) - import calendar - last_day = calendar.monthrange(year, month)[1] - target_date = datetime(year, month, last_day).strftime('%Y-%m-%d') + + # 计算当月第一天和最后一天 + first_day = datetime(year, month, 1).strftime('%Y-%m-%d') + last_day = datetime(year, month, calendar.monthrange(year, month)[1]).strftime('%Y-%m-%d') + if self.company_id: employees = self.env['hr.employee'].search([ ('company_id', '=', self.company_id.id), ('is_salary', '=', True), - ('entry_date', '<=', target_date), + ('entry_date', '<=', last_day), ('contract_id', '!=', False), '|', - ('contract_id.termination_date', '>=', target_date), + ('contract_id.termination_date', '>=', first_day), '|', '&', ('contract_id.termination_date', '=', False), - ('contract_id.date_end', '>=', target_date), + ('contract_id.date_end', '>=', first_day), '&', ('contract_id.termination_date', '=', False), ('contract_id.date_end', '=', False) ]) self.employee_ids = [(6, 0, employees.ids)] - self.employee_number = len(self.employee_ids) - for employee_id in self.employee_ids.ids: - employee = self.env['hr.employee'].browse(employee_id) - # 打印员工姓名 + self.employee_number = len(employees) + for employee in employees: print(f"员工姓名: {employee.name}") @api.onchange('employee_ids')