From af3727091a6d4968541128dc769096afe952fef5 Mon Sep 17 00:00:00 2001 From: odex Date: Wed, 14 Aug 2024 13:36:54 +0300 Subject: [PATCH] [IMP] FIX CALA HOLDAYS DURATION --- .../controllers/rest_api_v2/leave.py | 32 +++++++++++++------ 1 file changed, 23 insertions(+), 9 deletions(-) diff --git a/odex25_mobile/odex_mobile/controllers/rest_api_v2/leave.py b/odex25_mobile/odex_mobile/controllers/rest_api_v2/leave.py index 36b8a8046..574c92773 100644 --- a/odex25_mobile/odex_mobile/controllers/rest_api_v2/leave.py +++ b/odex25_mobile/odex_mobile/controllers/rest_api_v2/leave.py @@ -52,6 +52,7 @@ class LeaveController(http.Controller): 'issuing_deliver_custdy': hol.issuing_deliver_custdy, 'permission_request_for': hol.permission_request_for, 'issuing_exit_return': hol.issuing_exit_return, + # 'exit_return_duration': hol.number_of_days_temp, 'exit_return_duration': hol.exit_return_duration, 'ticket_cash_request_type_id': hol.ticket_cash_request_type.id if hol.ticket_cash_request_type else False, 'ticket_cash_request_type_name': hol.ticket_cash_request_type.name if hol.ticket_cash_request_type else False, @@ -227,12 +228,15 @@ class LeaveController(http.Controller): "You Have issue in your employee profile. please check with one of your team admins"), success=False) try: with request.env.cr.savepoint(): - vals = {'employee_id': employee.id, 'date_from': body['start_date'], 'date_to': body['end_date'] - , 'name': body['description'] if body.get('description') else '', - 'holiday_status_id': int(body['type_id']), - 'delegate_acc': body['delegated_permission'], - # 'replace_by': int(body['replacement_id']) if body['replacement_id'] else False - } + vals = { + "employee_id": employee.id, + "date_from": body["start_date"], + "date_to": body["end_date"], + "name": body["description"] if body.get("description") else "", + "holiday_status_id": int(body["type_id"]), + "delegate_acc": body["delegated_permission"], + # 'replace_by': int(body['replacement_id']) if body['replacement_id'] else False + } if 'ticket' in body and body['ticket']: vals.update({'issuing_clearance_form': body['issuing_clearance_form'], 'issuing_deliver_custdy': body[ @@ -259,9 +263,14 @@ class LeaveController(http.Controller): }) holidays.attach_ids = [(4,attach.id)] if holidays: + holidays._onchange_employee() + holidays._onchange_date_from() + holidays._onchange_date_to() + holidays._get_end_date() + holidays._get_holiday_related_date() # holidays.confirm() - holidays.number_of_days_temp = holidays._get_number_of_days(body['start_date'], body['end_date'], - employee) + # holidays.number_of_days_temp = holidays._get_number_of_days(body['start_date'], body['end_date'], + # employee) data = self.get_return_data(holidays) return http_helper.response(message=_("Leave Created Successfully"), data={'leaves': [data]}) except (UserError, AccessError, ValidationError, Exception, Warning) as e: @@ -335,7 +344,12 @@ class LeaveController(http.Controller): 'res_id': holidays.id, 'att_holiday_ids': holidays.id, }) - holidays.attach_ids = [(4,attach.id)] + holidays.attach_ids = [(4, attach.id)] + holidays._onchange_employee() + holidays._onchange_date_from() + holidays._onchange_date_to() + holidays._get_end_date() + holidays._get_holiday_related_date() data = self.get_return_data(holidays, approvel) return http_helper.response(message=_("Leave Updated Successfully"), data={'leaves': [data]}) else: