@@ -57,7 +57,7 @@ class HrPayrollStructure(models.Model):
|
||||
name_pinyin = pinyin(field_name, style=Style.FIRST_LETTER)
|
||||
code = "".join([p[0][0] for p in name_pinyin]).upper()
|
||||
salary_id = self.env['hr.salary.rule'].search(
|
||||
[('name', '=', field_name), ('struct_id', '=', self.id.origin)], limit=1)
|
||||
[('name', '=', field_name), ('struct_id', '=', self.id)], limit=1)
|
||||
if not salary_id:
|
||||
self.env['hr.salary.rule'].create({
|
||||
'name': field_name,
|
||||
@@ -110,15 +110,18 @@ class HrPayrollStructure(models.Model):
|
||||
|
||||
def write(self, vals):
|
||||
result = super(HrPayrollStructure, self).write(vals)
|
||||
field_mapping = {
|
||||
'base_salary': '基本工资',
|
||||
'rank_salary': '职级工资',
|
||||
'communication_subsidy': '通讯补贴',
|
||||
'position_salary': '岗位工资'
|
||||
}
|
||||
for field, name in field_mapping.items():
|
||||
if field in vals:
|
||||
self._handle_salary_rule(name, self[field])
|
||||
if result:
|
||||
field_mapping = {
|
||||
'base_salary': '基本工资',
|
||||
'rank_salary': '职级工资',
|
||||
'communication_subsidy': '通讯补贴',
|
||||
'position_salary': '岗位工资',
|
||||
'advance_performance_bonuses': '预发绩效奖金' # 补充新增字段
|
||||
}
|
||||
for record in self:
|
||||
for field, name in field_mapping.items():
|
||||
if field in vals:
|
||||
record._handle_salary_rule(name, record[field])
|
||||
return result
|
||||
|
||||
def action_yuthon_payroll_wizard(self):
|
||||
@@ -235,18 +238,16 @@ class HrPayrollStructure(models.Model):
|
||||
|
||||
def rank_log_time(self):
|
||||
"""定时任务:根据日志记录的生效时间更新主模型字段值"""
|
||||
# 出发一下
|
||||
today = date.today()
|
||||
for structure in self.env['hr.payroll.structure'].search([('company_id.name', '=', '集团本部')]):
|
||||
# 获取该职级下所有有效的日志记录
|
||||
valid_logs = structure.renk_log_ids.filtered(
|
||||
lambda log: log.is_enable and
|
||||
log.effective_date and
|
||||
log.effective_date <= today and
|
||||
(not log.lapse_date or log.lapse_date >= today)
|
||||
lambda log: log.is_enable and log.effective_date and log.effective_date <= today and (not log.lapse_date or log.lapse_date >= today)
|
||||
).sorted(key=lambda l: l.effective_date, reverse=True)
|
||||
if valid_logs:
|
||||
latest_log = valid_logs[0]
|
||||
structure.write({
|
||||
structure.sudo().write({
|
||||
'base_salary': latest_log.base_salary,
|
||||
'rank_salary': latest_log.rank_salary,
|
||||
'communication_subsidy': latest_log.communication_subsidy,
|
||||
|
||||
Reference in New Issue
Block a user