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