commit
3bba4af0e1
|
|
@ -86,7 +86,7 @@ class LeaveController(http.Controller):
|
|||
status = http.request.env['hr.holidays.status'].search([('id', 'in', my_leave)])
|
||||
domain = [('state', '!=', 'draft')]
|
||||
alternative_employees = http.request.env['hr.employee'].search_read(
|
||||
[('state', '=', 'open'), ('id', '!=', employee.id)], ['name'])
|
||||
[('state', '=', 'open')], ['name'])
|
||||
if approvel:
|
||||
holidays = http.request.env['hr.holidays'].search(
|
||||
[('state', 'in', ['confirm','validate','approved']), ('employee_id', '!=', employee.id), ('type', '=', 'remove')],
|
||||
|
|
@ -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'],
|
||||
|
|
@ -243,10 +245,12 @@ class LeaveController(http.Controller):
|
|||
message = validator.get_server_error(e, user)
|
||||
return http_helper.errcode(code=403, message=message)
|
||||
|
||||
@http.route(['/rest_api/v2/leaves/<string:id>'], type='http', auth='none', csrf=False, methods=['PUT'])
|
||||
@http.route(['/rest_api/v2/leaves/<int:id>'], type='http', auth='none', csrf=False, methods=['PUT'])
|
||||
def edit_leaves(self, id, approvel=None, **kw):
|
||||
http_method, body, headers, token = http_helper.parse_request()
|
||||
result = validator.verify_token(token)
|
||||
# import pdb
|
||||
# pdb.set_trace()
|
||||
if not result['status']:
|
||||
return http_helper.errcode(code=result['code'], message=result['message'])
|
||||
user = validator.verify(token)
|
||||
|
|
@ -265,7 +269,10 @@ class LeaveController(http.Controller):
|
|||
"You Have issue in your employee profile. please check with one of your team admins"),
|
||||
success=False)
|
||||
try:
|
||||
holidays = http.request.env['hr.holidays'].search([('id', '=', id)])
|
||||
holidays = http.request.env['hr.holidays'].search([('id', '=', int(id))])
|
||||
print(holidays, id)
|
||||
|
||||
|
||||
if holidays:
|
||||
days = holidays._get_number_of_days(body['start_date'], body['end_date'], employee)
|
||||
vals = {
|
||||
|
|
@ -299,10 +306,17 @@ class LeaveController(http.Controller):
|
|||
'store_fname': body['attachment'].filename,
|
||||
'res_model': 'hr.holidays',
|
||||
'res_id': holidays.id,
|
||||
'att_holiday_ids': holidays.id,
|
||||
})
|
||||
holidays.attach_ids = [(4,attach.id)]
|
||||
data = self.get_return_data(holidays, approvel)
|
||||
|
||||
return http_helper.response(message=_("Leave Updated Successfully"), data={'leaves': [data]})
|
||||
|
||||
else:
|
||||
return http_helper.response(code=400,
|
||||
message=_(
|
||||
"You Have issue in your employee profile. please check with one of your team admins"),
|
||||
success=False)
|
||||
except Exception as e:
|
||||
_logger.error(str(e))
|
||||
message = validator.get_server_error(e, user)
|
||||
|
|
|
|||
Loading…
Reference in New Issue