From 0b7b487cf03792b4f37039515853d724e8527499 Mon Sep 17 00:00:00 2001 From: odex Date: Tue, 16 Jul 2024 15:35:04 +0300 Subject: [PATCH] fix 001 --- .../odex_mobile/controllers/authentication.py | 1 + .../controllers/rest_api_v2/authentication.py | 1 + .../controllers/rest_api_v2/overtime.py | 10 +++---- .../controllers/rest_api_v2/permission.py | 29 +++++++++++++++---- 4 files changed, 30 insertions(+), 11 deletions(-) diff --git a/odex25_mobile/odex_mobile/controllers/authentication.py b/odex25_mobile/odex_mobile/controllers/authentication.py index a69d9d6fd..8c3066978 100644 --- a/odex25_mobile/odex_mobile/controllers/authentication.py +++ b/odex25_mobile/odex_mobile/controllers/authentication.py @@ -198,5 +198,6 @@ class AuthenticationController(http.Controller): employee.sudo().write({'fcm_token':kw.get('fcm_token')}) dic['token'] = token + dic['is_approve'] = 'group_division_manager' in dic.get('groups',[]) http_helper.cleanup(); return http_helper.response(data=dic, message=_("User log in successfully")) diff --git a/odex25_mobile/odex_mobile/controllers/rest_api_v2/authentication.py b/odex25_mobile/odex_mobile/controllers/rest_api_v2/authentication.py index d2e5f3c84..06f590b9b 100644 --- a/odex25_mobile/odex_mobile/controllers/rest_api_v2/authentication.py +++ b/odex25_mobile/odex_mobile/controllers/rest_api_v2/authentication.py @@ -199,5 +199,6 @@ class AuthenticationController(http.Controller): employee.sudo().write({'fcm_token':kw.get('fcm_token')}) dic['token'] = token + dic['is_approve'] = 'group_division_manager' in dic.get('groups',[]) http_helper.cleanup(); return http_helper.response(data=dic, message=_("User log in successfully")) diff --git a/odex25_mobile/odex_mobile/controllers/rest_api_v2/overtime.py b/odex25_mobile/odex_mobile/controllers/rest_api_v2/overtime.py index 24f6b7e6e..af93f740a 100644 --- a/odex25_mobile/odex_mobile/controllers/rest_api_v2/overtime.py +++ b/odex25_mobile/odex_mobile/controllers/rest_api_v2/overtime.py @@ -84,7 +84,7 @@ class OverTimeController(http.Controller): "state": validator.get_state_name(s, s.state), "reason": s.reason, "reason_msg": s.reason or "", - "overtime_plase": s.overtime_plase, + "overtime_plase": http_helper.get_lable_selection(s,'overtime_plase',s.overtime_plase),# s.overtime_plase, } if approvel: value.update({ @@ -210,7 +210,7 @@ class OverTimeController(http.Controller): "state_name": s.state, "state": validator.get_state_name(s, s.state), "reason": s.reason, - "overtime_plase": s.overtime_plase, + "overtime_plase": http_helper.get_lable_selection(s,'overtime_plase',s.overtime_plase),#s.overtime_plase, } li = [] if s.line_ids_over_time: @@ -288,7 +288,7 @@ class OverTimeController(http.Controller): "date_from": body["date_from"], "date_to": body["date_to"], "reason": body["reason"], - "overtime_plase": s.overtime_plase, + "overtime_plase": http_helper.get_lable_selection(s,'overtime_plase',s.overtime_plase),#s.overtime_plase, } if approvel: @@ -312,7 +312,7 @@ class OverTimeController(http.Controller): "transfer_type": http_helper.get_lable_selection(s,'transfer_type',s.transfer_type),# s.transfer_type, "request_date": str(s.request_date), "date_from": str(s.date_from), - "overtime_plase": s.overtime_plase, + "overtime_plase":http_helper.get_lable_selection(s,'overtime_plase',s.overtime_plase),# s.overtime_plase, "date_to": str(s.date_to), "state_name": s.state, "state": validator.get_state_name(s, s.state), @@ -462,7 +462,7 @@ class OverTimeController(http.Controller): "state_name": s.state, "state": validator.get_state_name(s, s.state), "reason": s.reason, - "overtime_plase": s.overtime_plase, + "overtime_plase": http_helper.get_lable_selection(s,'overtime_plase',s.overtime_plase),#s.overtime_plase, } if approvel: value.update({ diff --git a/odex25_mobile/odex_mobile/controllers/rest_api_v2/permission.py b/odex25_mobile/odex_mobile/controllers/rest_api_v2/permission.py index ff11322bd..55c07be79 100644 --- a/odex25_mobile/odex_mobile/controllers/rest_api_v2/permission.py +++ b/odex25_mobile/odex_mobile/controllers/rest_api_v2/permission.py @@ -63,6 +63,7 @@ class PermissionController(http.Controller): "state_name": per.state, "early_exit": per.early_exit, "reason_msg": per.reason or "", + "mission_purpose": per.mission_purpose or "", "attachment": self.get_attchment(per), } emp.append(value) @@ -94,6 +95,8 @@ class PermissionController(http.Controller): success=False) if not body.get('early_exit'): return http_helper.response(code=400, message="Enter Early Exit for Permission request", success=False) + if not body.get('mission_purpose'): + return http_helper.response(code=400, message="mission purpose for Permission request", success=False) employee = http.request.env['hr.employee'].search([('user_id', '=', user.id)], limit=1) if not employee: return http_helper.response(code=400, @@ -102,12 +105,21 @@ class PermissionController(http.Controller): success=False) try: permission_number = self.permission_number_decrement(employee, body['date_from'], body['date_to']) - permission = http.request.env['hr.personal.permission'].sudo().create( - {'employee_id': employee.id, 'date_from': body['date_from'], 'date_to': body['date_to'], - 'early_exit': body['early_exit'], 'permission_number': permission_number, - 'date': body['date'], - - }) + permission = ( + http.request.env["hr.personal.permission"] + .sudo() + .create( + { + "employee_id": employee.id, + "date_from": body["date_from"], + "date_to": body["date_to"], + "early_exit": body["early_exit"], + "mission_purpose": body["mission_purpose"], + "permission_number": permission_number, + "date": body["date"], + } + ) + ) permission.permission_number_decrement() if 'attachment' in body and body['attachment']: attach = http.request.env['ir.attachment'].sudo().create({ @@ -131,6 +143,7 @@ class PermissionController(http.Controller): "state": validator.get_state_name(permission, permission.state), "state_name": permission.state, "reason_msg": permission.reason or "", + "reason_msg": permission.mission_purpose or "", "attachment": self.get_attchment(permission), } return http_helper.response(message="Permission Created Successfully", data={'permission': [data]}) @@ -172,6 +185,7 @@ class PermissionController(http.Controller): 'date_to': body['date_to'], 'early_exit': body['early_exit'], 'date': body['date'], + 'mission_purpose': body['mission_purpose'], }) if 'attachment' in body and body['attachment']: @@ -183,6 +197,7 @@ class PermissionController(http.Controller): 'res_id': permission.id, 'personal_permission_id': permission.id, }) + permission = http.request.env['hr.personal.permission'].search([('id', '=', id)]) data = { "id": permission.id, "date": str(permission.date), @@ -191,6 +206,7 @@ class PermissionController(http.Controller): "date_to": str(permission.date_to), "early_exit": permission.early_exit, "reason_msg": permission.reason or "", + "mission_purpose": permission.mission_purpose or "", "state": validator.get_state_name(permission, permission.state), "state_name": permission.state, "attachment": self.get_attchment(permission), @@ -239,6 +255,7 @@ class PermissionController(http.Controller): "date_to": str(permission.date_to), "early_exit": permission.early_exit, "reason_msg": permission.reason or "", + "mission_purpose": permission.mission_purpose or "", "state": validator.get_state_name(permission, permission.state), "state_name": permission.state, "attachment": self.get_attchment(permission),