employee_id = kwargs.setdefault('values', {}).get('employee_id',None) or result.get('employee_id',None)
employee = env['hr.employee'].search([('id','=',employee_id.id)])
if employee.employee_type_rep.code in ['ET02','ET03','ET04']:
result.update(
{
'housing_fund_end_month': '',
'social_security_end_month':''
}
)
else:
leave_time = kwargs.setdefault('values', {}).get('leave_time',None) or result.get('leave_time',None)
if int(leave_time[-2:]) <20:
new_month = str(int(leave_time[5:7])-1)
if int(new_month)<=0:
new_month = '12'
new_day = str(int(leave_time[0:4])1)''+str(new_month)'-01'
next_month = toolkits.datetime.datetime.strptime(new_day,'%Y-%m-%d').replace(day=28) + toolkits.datetime.timedelta(days=4)
new_day = (next_month - toolkits.datetime.timedelta(days=next_month.day)).strftime('%Y-%m-%d')
if len(new_month)<2:
new_month = '0'+new_month
new_day = leave_time[0:5]str(new_month)'-01'
next_month = toolkits.datetime.datetime.strptime(new_day,'%Y-%m-%d').replace(day=28) + toolkits.datetime.timedelta(days=4)
new_day = (next_month - toolkits.datetime.timedelta(days=next_month.day)).strftime('%Y-%m-%d')
result.update(
{
'social_security_end_month':new_day,
'housing_fund_end_month':new_day
}
)
elif int(leave_time[-2:]) >= 20:
next_month = toolkits.datetime.datetime.strptime(leave_time,'%Y-%m-%d').replace(day=28) + toolkits.datetime.timedelta(days=4)
new_day = (next_month - toolkits.datetime.timedelta(days=next_month.day)).strftime('%Y-%m-%d')
result.update(
{
'social_security_end_month':new_day,
'housing_fund_end_month':new_day
}
)