From db4c4c4c5c96e37c8cc4c9fd39e6609bdca32af9 Mon Sep 17 00:00:00 2001 From: zhou <123@> Date: Wed, 9 Apr 2025 17:55:00 +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_hr_employee/models/yuthon_hr_employee.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/yuthon_hr_employee/models/yuthon_hr_employee.py b/yuthon_hr_employee/models/yuthon_hr_employee.py index b1f110adf..8af9206cb 100644 --- a/yuthon_hr_employee/models/yuthon_hr_employee.py +++ b/yuthon_hr_employee/models/yuthon_hr_employee.py @@ -155,7 +155,7 @@ class YuthonHrEmployee(models.Model): pinyin_min = fields.Char(string='拼音缩写', compute='_compute_pinyin', index=True, store=True) # 工资计算分组 - salary_group_id = fields.Many2one('yuthon.salary.group', string="工资单分组", store=True, index=True) + salary_group_id = fields.Many2one(related='contract_id.salary_group_id', string="工资单分组", store=True, index=True, compute='_compute_salary_group_id') last_year_salary = fields.Float(string="年金基数") social_base_on = fields.Float(string="1-6月社保薪资基数") social_base_off = fields.Float(string="7-12月社保薪资基数") @@ -169,6 +169,15 @@ class YuthonHrEmployee(models.Model): housing_fund_base = fields.Float(string='住房公积金基数', compute='_compute_insurance_bases') last_attendance = fields.Boolean(string="上月全勤", store=True) + @api.depends('contract_id') + def _compute_salary_group_id(self): + for employee in self: + contract_id = self.env['hr.contract'].search([('employee_id', '=', employee.id)], limit=1) + if contract_id: + employee.salary_group_id = contract_id.salary_group_id.id + else: + employee.salary_group_id = False + @api.depends('social_base_on', 'social_base_off') def _compute_insurance_bases(self): current_month = datetime.now().month