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 4abf6854c..7e9e138d3 100644 --- a/odex25_mobile/odex_mobile/controllers/rest_api_v2/authentication.py +++ b/odex25_mobile/odex_mobile/controllers/rest_api_v2/authentication.py @@ -3,6 +3,7 @@ import werkzeug from odoo import http,tools from odoo.http import request, Response from odoo.addons.auth_signup.models.res_users import SignupError +from odoo.addons.web.controllers.main import ensure_db from odoo.exceptions import UserError ,AccessError, ValidationError import base64 # from odoo.addons.odex_mobile.validator import validator @@ -216,6 +217,9 @@ class AuthenticationController(http.Controller): @http.route('/rest_api/login', type='http', auth='none', csrf=False, cors='*', methods=['POST']) def login_phone(self, **kw): + if not kw: + kw = json.loads(http.request.httprequest.data) + db = kw.get('db') start_time_pc = time.perf_counter() login=kw.get('login') password=kw.get('password') @@ -230,6 +234,9 @@ class AuthenticationController(http.Controller): #check fcm_token if not kw.get('fcm_token'): return http_helper.response(code=400,message=_('FCM Token is missing'),success=False) + # Set the database for the request environment + if db: + ensure_db() user = request.env['res.users'].sudo().search([('login', '=',login)], limit=1) 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 5f5fb5835..a8957e672 100644 --- a/odex25_mobile/odex_mobile/controllers/rest_api_v2/leave.py +++ b/odex25_mobile/odex_mobile/controllers/rest_api_v2/leave.py @@ -26,7 +26,7 @@ _logger = logging.getLogger(__name__) class LeaveController(http.Controller): def get_attchment(self, res_id): - attachment = http.request.env['ir.attachment'].search( + attachment = http.request.env['ir.attachment'].sudo().search( [('res_model', '=', 'hr.holidays'), ('res_id', '=', res_id.id)]) li = [] if attachment: @@ -85,7 +85,7 @@ class LeaveController(http.Controller): employees = http.request.env['hr.employee'].sudo().search( [('department_id', '=', employee.department_id.id), ('state', '=', 'open'), ('id', '!=', employee.id), '|', ('parent_id', '=', employee.id), ('coach_id', '=', employee.id)]) - balance = http.request.env['hr.holidays'].search( + balance = http.request.env['hr.holidays'].with_user(user.id).search( [('employee_id', '=', employee.id), ('type', '=', 'add'), ('check_allocation_view', '=', 'balance'),('remaining_leaves','>',0)]) my_leave = balance.mapped('holiday_status_id').ids status = http.request.env['hr.holidays.status'].search([('id', 'in', my_leave),('leave_type','!=','sick')]) @@ -95,21 +95,21 @@ class LeaveController(http.Controller): alternative_employees = http.request.env['hr.employee'].search_read( [('state', '=', 'open')], ['name']) if approvel: - holidays = http.request.env['hr.holidays'].search( + holidays = http.request.env['hr.holidays'].with_user(user.id).search( [('state', 'in', ['confirm','validate','approved']), ('employee_id', '!=', employee.id), ('type', '=', 'remove')], offset=offset, limit=limit) - count = http.request.env['hr.holidays'].search_count( + count = http.request.env['hr.holidays'].with_user(user.id).search_count( [('state', 'in', ['confirm','validate','approved']), ('employee_id', '!=', employee.id), ('type', '=', 'remove')],) elif done: - holidays = http.request.env['hr.holidays'].search( + holidays = http.request.env['hr.holidays'].with_user(user.id).search( [('state', 'in', ['validate1','refuse','cancel']), ('employee_id', '!=', employee.id), ('type', '=', 'remove')], offset=offset, limit=limit) - count = http.request.env['hr.holidays'].search_count( + count = http.request.env['hr.holidays'].with_user(user.id).search_count( [('state', 'in', ['validate1','refuse','cancel']), ('employee_id', '!=', employee.id), ('type', '=', 'remove')],) else: - holidays = http.request.env['hr.holidays'].search( + holidays = http.request.env['hr.holidays'].with_user(user.id).search( [('employee_id', '=', employee.id), ('type', '=', 'remove')], offset=offset, limit=limit) - count = http.request.env['hr.holidays'].search_count( + count = http.request.env['hr.holidays'].with_user(user.id).search_count( [('employee_id', '=', employee.id), ('type', '=', 'remove')],) ticket_cash_type = http.request.env['hr.ticket.request.type'].search([]) ticket_cash = [] @@ -393,7 +393,7 @@ class LeaveController(http.Controller): holidays._onchange_date_from() holidays._onchange_date_to() holidays._get_end_date() - holidays._get_holiday_related_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: diff --git a/odex25_mobile/odex_mobile/controllers/rest_api_v2/official_mission.py b/odex25_mobile/odex_mobile/controllers/rest_api_v2/official_mission.py index fe0064ee8..b7f71cd51 100644 --- a/odex25_mobile/odex_mobile/controllers/rest_api_v2/official_mission.py +++ b/odex25_mobile/odex_mobile/controllers/rest_api_v2/official_mission.py @@ -256,20 +256,24 @@ class HrOfficialMissionController(http.Controller): # Create the record # Prepare the response - mission_type = kw.get('mission_type') - mission_purpose = kw.get('mission_purpose','') - date_from = kw.get('date_from') - date_to = kw.get('date_to') - hour_from = kw.get('hour_from', 8) - hour_to = kw.get('hour_to', 16) - destination_type = kw.get('destination') + mission_type = body.get('mission_type') + mission_purpose = body.get('mission_purpose','') + date_from = body.get('date_from') + date_to = body.get('date_to') + hour_from = body.get('hour_from', 8) + hour_to = body.get('hour_to', 16) + destination_type = body.get('destination') try: - hour_from = float(kw.get('hour_from') or 8) + hour_from = float(body.get('hour_from') or 8) + if hour_from == 0.0: + hour_from = 8.0 except: hour_from = 8.0 try: - hour_to = float(kw.get('hour_to') or 16) + hour_to = float(body.get('hour_to') or 16) + if hour_to == 0.0: + hour_to = 16.0 except: hour_to = 16.0 @@ -299,9 +303,11 @@ class HrOfficialMissionController(http.Controller): 'hours': mission.hour_duration, }) if mission_employee: - # mission_employee.chick_not_overtime() mission_employee.compute_number_of_days() mission_employee.compute_number_of_hours() + mission_employee.compute_day_price() + mission_employee.compute_Training_cost_emp() + mission_employee.chick_not_overtime() mis = request.env['hr.official.mission'].sudo().search([('id', '=', mission.id)]) diff --git a/odex25_mobile/odex_mobile/models/attendence_zone_config.py b/odex25_mobile/odex_mobile/models/attendence_zone_config.py index 537e3a3bd..c509c3022 100644 --- a/odex25_mobile/odex_mobile/models/attendence_zone_config.py +++ b/odex25_mobile/odex_mobile/models/attendence_zone_config.py @@ -58,6 +58,12 @@ class AttendanceZone(models.Model): for r in record: r.active_check = False + @api.model + def get_coordinates(self): + coordinates = self.env['attendance.zone'].search([], limit=1) + data = {"lng":coordinates.longitude,"lat": coordinates.latitude,'range':coordinates.allowed_range} + return data + class ResConfigSettings(models.TransientModel): _inherit = 'res.config.settings' diff --git a/odex25_mobile/odex_mobile/security/ir.model.access.csv b/odex25_mobile/odex_mobile/security/ir.model.access.csv index e3b679069..f39a2b359 100644 --- a/odex25_mobile/odex_mobile/security/ir.model.access.csv +++ b/odex25_mobile/odex_mobile/security/ir.model.access.csv @@ -1,7 +1,8 @@ id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink access_jwt_access_token,Read.jwt.access.token,model_jwt_provider_access_token,,1,1,1,1 -access_attendance_zone,access_attendance_zone,model_attendance_zone,base.group_user,1,1,1,0 +access_attendance_zone,access_attendance_zone,model_attendance_zone,base.group_user,1,0,0,0 access_attendance_log,access_attendance_log,model_attendance_log,base.group_user,1,1,1,0 access_firebase_registration_registration_user,access_firebase_registration,model_firebase_registration,base.group_user,1,1,1,1 access_mobile_notification_user_employee,access_mobile_notification_employee,model_employee_notification,base.group_user,1,1,1,1 access_firebase_notification_user,access_firebase_notification,model_firebase_notification,base.group_user,1,1,1,1 +access_attendance_zone_hr,access_attendance_zone_hr,model_attendance_zone,hr.group_hr_user,1,1,1,1