fix some bug

This commit is contained in:
odex 2024-07-11 18:17:29 +03:00
parent 7d2493cbed
commit 54de749578
1 changed files with 8 additions and 7 deletions

View File

@ -225,12 +225,14 @@ class LeaveController(http.Controller):
holidays = http.request.env['hr.holidays'].sudo().create(vals)
if 'attachment' in body and body['attachment']:
attach = http.request.env['ir.attachment'].sudo().create({
'name': body['attachment'].filename,
'datas': base64.b64encode(body['attachment'].read()),
'store_fname': body['attachment'].filename,
'res_model': 'hr.holidays',
'res_id': holidays.id,
})
'name': body['attachment'].filename,
'datas': base64.b64encode(body['attachment'].read()),
'store_fname': body['attachment'].filename,
'res_model': 'hr.holidays',
'res_id': holidays.id,
'att_holiday_ids': holidays.id,
})
holidays.attach_ids = [(4,attach.id)]
if holidays:
# holidays.confirm()
holidays.number_of_days_temp = holidays._get_number_of_days(body['start_date'], body['end_date'],
@ -306,7 +308,6 @@ class LeaveController(http.Controller):
'res_id': holidays.id,
'att_holiday_ids': holidays.id,
})
print(attach)
holidays.attach_ids = [(4,attach.id)]
data = self.get_return_data(holidays, approvel)
return http_helper.response(message=_("Leave Updated Successfully"), data={'leaves': [data]})