From e793c9ba12c3139dc32711f477e074d3bbd160d9 Mon Sep 17 00:00:00 2001 From: odex Date: Thu, 11 Jul 2024 17:33:28 +0300 Subject: [PATCH 1/3] fix some bug --- odex25_mobile/odex_mobile/controllers/rest_api_v2/leave.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 1a9a93e07..43c396213 100644 --- a/odex25_mobile/odex_mobile/controllers/rest_api_v2/leave.py +++ b/odex25_mobile/odex_mobile/controllers/rest_api_v2/leave.py @@ -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')], From 7d2493cbede049e8879517067db54e9c473eab3b Mon Sep 17 00:00:00 2001 From: odex Date: Thu, 11 Jul 2024 18:16:42 +0300 Subject: [PATCH 2/3] fix some bug --- .../controllers/rest_api_v2/leave.py | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 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 43c396213..c5a12f3e9 100644 --- a/odex25_mobile/odex_mobile/controllers/rest_api_v2/leave.py +++ b/odex25_mobile/odex_mobile/controllers/rest_api_v2/leave.py @@ -243,10 +243,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/'], type='http', auth='none', csrf=False, methods=['PUT']) + @http.route(['/rest_api/v2/leaves/'], 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 +267,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 +304,18 @@ class LeaveController(http.Controller): 'store_fname': body['attachment'].filename, 'res_model': 'hr.holidays', '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]}) + + 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) From 54de7495784fc0f0f32cf3ae7ace7614b9882a04 Mon Sep 17 00:00:00 2001 From: odex Date: Thu, 11 Jul 2024 18:17:29 +0300 Subject: [PATCH 3/3] fix some bug --- .../odex_mobile/controllers/rest_api_v2/leave.py | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 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 c5a12f3e9..1fbdee646 100644 --- a/odex25_mobile/odex_mobile/controllers/rest_api_v2/leave.py +++ b/odex25_mobile/odex_mobile/controllers/rest_api_v2/leave.py @@ -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]})