values = kwargs.setdefault('values', {})
# 入职日期
hiredate = values.get('hiredate')
# 员工分组
employee_group_rep = values.get('employee_group_rep')
# 社保公积金默认值
social_security_start_month, housing_fund_start_month = '', ''
if isinstance(employee_group_rep, int):
employee_group_rep = env['hr.employee.group'].search([('id', '=', employee_group_rep)])
if hiredate:
if isinstance(hiredate, str):
hiredate = toolkits.datetime.datetime.strptime(hiredate, '%Y-%m-%d')
# housing_fund_start_month 公积金起缴月、social_security_start_month 社保起缴月
if employee_group_rep.code == 'G001':
if hiredate.day > 15:
social_security_start_month = toolkits.datetime.datetime(hiredate.year + (hiredate.month == 12), hiredate.month == 12 or hiredate.month +1 , 1).date()
housing_fund_start_month = social_security_start_month
else:
social_security_start_month = hiredate.replace(day=1)
housing_fund_start_month = hiredate.replace(day=1)
elif employee_group_rep.code == 'G002':
social_security_start_month = hiredate.replace(day=1)
housing_fund_start_month = hiredate.replace(day=1)
if social_security_start_month:
result.update({'social_security_start_month': social_security_start_month})
if housing_fund_start_month:
result.update({'housing_fund_start_month': housing_fund_start_month})