Merge remote-tracking branch 'origin/dev_odex25_mobile' into dev_odex25_mobile

This commit is contained in:
Bakry 2024-08-04 10:54:52 +03:00
commit aba4745ecc
4 changed files with 71 additions and 34 deletions

View File

@ -29,12 +29,12 @@ jobs:
deploy_master_server:
name: Deploy to Master
runs-on: ensan-client-project-runner
if: github.event_name == 'workflow_dispatch' && (github.ref == 'refs/heads/master_odex-event' || github.ref == 'refs/heads/master_odex25_accounting' || github.ref == 'refs/heads/master_odex25_base' || github.ref == 'refs/heads/master_odex25_dms' || github.ref == 'refs/heads/master_odex25_fleet' || github.ref == 'refs/heads/master_odex25_ENSAN' || github.ref == 'refs/heads/master_odex25_hr' || github.ref == 'refs/heads/master_odex25_inventory' || github.ref == 'refs/heads/master_odex25_maintenance' || github.ref == 'refs/heads/master_odex25_mobile' || github.ref == 'refs/heads/master_odex25_pos' || github.ref == 'refs/heads/master_odex25_project' || github.ref == 'refs/heads/master_odex25_purchase' || github.ref == 'refs/heads/master_odex25_realstate' || github.ref == 'refs/heads/master_odex25_sales' || github.ref == 'refs/heads/master_odex25_survey' || github.ref == 'refs/heads/master_odex25_transactions' || github.ref == 'refs/heads/master_odex25_website' || github.ref == 'refs/heads/master_openeducat_erp-14.0.1.0')
if: github.ref == 'refs/heads/master_odex-event' || github.ref == 'refs/heads/master_odex25_accounting' || github.ref == 'refs/heads/master_odex25_base' || github.ref == 'refs/heads/master_odex25_dms' || github.ref == 'refs/heads/master_odex25_fleet' || github.ref == 'refs/heads/master_odex25_ENSAN' || github.ref == 'refs/heads/master_odex25_hr' || github.ref == 'refs/heads/master_odex25_inventory' || github.ref == 'refs/heads/master_odex25_maintenance' || github.ref == 'refs/heads/master_odex25_mobile' || github.ref == 'refs/heads/master_odex25_pos' || github.ref == 'refs/heads/master_odex25_project' || github.ref == 'refs/heads/master_odex25_purchase' || github.ref == 'refs/heads/master_odex25_realstate' || github.ref == 'refs/heads/master_odex25_sales' || github.ref == 'refs/heads/master_odex25_survey' || github.ref == 'refs/heads/master_odex25_transactions' || github.ref == 'refs/heads/master_odex25_website' || github.ref == 'refs/heads/master_openeducat_erp-14.0.1.0'
steps:
- name: Checkout And Restart Project
run: |
echo "** [INFO] Running on branch --> ${GITHUB_REF#refs/heads/}"
sudo chmod +x ${{ secrets.ENSAN_PROJECT_PATH }}/scripts/pull_code.sh
sudo ${{ secrets.ENSAN_PROJECT_PATH }}/scripts/pull_code.sh ${{ secrets.ENSAN_PROJECT_USER }} ${{ secrets.ENSAN_PROJECT_PATH }} ${{ secrets.ENSAN_MASTER_SERVICE }} master ${GITHUB_REF#refs/heads/master_} ${GITHUB_REF#refs/heads/}
sudo chmod +x ${{ secrets.ENSAN_STANDARD_FOLDER_PATH }}/scripts/pull_code.sh
sudo ${{ secrets.ENSAN_STANDARD_FOLDER_PATH }}/scripts/pull_code.sh ${{ secrets.ENSAN_PROJECT_USER }} ${{ secrets.ENSAN_STANDARD_FOLDER_PATH }} ${{ secrets.ENSAN_MASTER_SERVICE }} master ${GITHUB_REF#refs/heads/master_} ${GITHUB_REF#refs/heads/}

View File

@ -81,11 +81,11 @@ class AuthenticationController(http.Controller):
if not user:
return http_helper.errcode(code=400, message=_("You are not allowed to perform this operation. please check with one of your team admins"))
if not http_helper.is_authentic(user.login, body.get('new_password')):
if not http_helper.is_authentic(user.login, body.get('old_password')):
return http_helper.errcode(code=400, message='Invalid passwords')
res = request.env.user.sudo().write({
'password':str(body.get('old_password')).strip()
'password':str(body.get('new_password')).strip()
})
# # change_password(self, old_passwd, new_passwd)

View File

@ -4,8 +4,8 @@ import calendar
from odoo import http, tools
from odoo.http import request, Response
from odoo.addons.auth_signup.models.res_users import SignupError
from odoo.exceptions import UserError ,AccessError, ValidationError
from datetime import datetime ,timedelta
from odoo.exceptions import UserError , AccessError, ValidationError
from datetime import datetime , timedelta
import base64
from ...validator import validator
from ...http_helper import http_helper
@ -267,58 +267,91 @@ class AttendanceController(http.Controller):
last = calendar.monthrange(year, month)[1]
month_end = datetime(year, month, last).date()
try:
records = http.request.env['hr.attendance.transaction'].search([('employee_id', '=', employee.id),
records = http.request.env['hr.attendance.transaction'].sudo().search([('employee_id', '=', employee.id),
('date', '>=', str(month_start)), ('date', '<=', str(month_end))])
# records = http.request.env['hr.attendance.transaction'].search([('employee_id','=',employee.id),
# ('normal_leave', '=', False),('public_holiday', '=', False), ('is_absent','=',False),('date', '>=', str(month_start)), ('date', '<=', str(month_end))])
# ('normal_leave', '=', True),('public_holiday', '=', True), ('is_absent','=',True),('date', '>=', str(month_start)), ('date', '<=', str(month_end))])
li = []
total_months = {}
if records:
records.get_hours()
total_plan_hours = sum(records.mapped('plan_hours'))
total_office_hours = sum(records.mapped('office_hours'))
total_additional_hours = sum(records.mapped('additional_hours'))
total_mission_hours = sum(records.mapped('total_mission_hours'))
total_public_holiday = sum(records.filtered(lambda rec:rec.public_holiday == True).mapped('plan_hours'))
total_normal_leave = sum(records.filtered(lambda rec:rec.normal_leave == True).mapped('plan_hours'))
total_absent = sum(records.filtered(lambda rec:rec.is_absent == True).mapped('plan_hours'))
total_approve_lateness = sum(records.mapped('lateness'))
total_early_exit = sum(records.mapped('early_exit'))
total_permission_hours = sum(records.mapped('total_permission_hours'))
total_months = {
'total_plan_hours':self.convert_float_total_time(total_plan_hours),
'tr_total_plan_hours':self.get_translation_field(records[0], 'plan_hours'),
'total_additional_hours':self.convert_float_total_time(total_additional_hours),
'tr_total_additional_hours':self.get_translation_field(records[0], 'additional_hours'),
'total_normal_leave':self.convert_float_total_time(total_normal_leave),
'tr_total_normal_leave':self.get_translation_field(records[0], 'normal_leave'),
'total_total_permission_hours':self.convert_float_total_time(total_permission_hours),
'tr_total_total_permission_hours':self.get_translation_field(records[0], 'total_permission_hours'),
'total_office_hours':self.convert_float_total_time(total_office_hours + total_public_holiday + total_mission_hours),
'tr_total_office_hours':self.get_translation_field(records[0], 'office_hours'),
'total_absent':self.convert_float_total_time(total_absent + total_approve_lateness + total_early_exit),
'tr_total_absent':self.get_translation_field(records[0], 'is_absent'),
}
for rec in records:
attendance = {
'id':rec.id,
'date':str(rec.date),
'tr_date':self.get_translation_field(rec,'date'),
'tr_date':self.get_translation_field(rec, 'date'),
'first_check_in':self.convert_float_2time(rec.sign_in),
'tr_sign_in':self.get_translation_field(rec,'sign_in'),
'tr_sign_in':self.get_translation_field(rec, 'sign_in'),
'last_check_out':self.convert_float_2time(rec.sign_out),
'tr_sign_out':self.get_translation_field(rec,'sign_out'),
'tr_sign_out':self.get_translation_field(rec, 'sign_out'),
'total_time':self.convert_float_2time(rec.office_hours),
'tr_office_hours':self.get_translation_field(rec,'office_hours'),
'tr_office_hours':self.get_translation_field(rec, 'office_hours'),
'total_lateness_hours':self.convert_float_2time(rec.lateness),
'approve_lateness':rec.approve_lateness,
'tr_approve_lateness':self.get_translation_field(rec,'approve_lateness'),
'tr_approve_lateness':self.get_translation_field(rec, 'approve_lateness'),
'total_early_exit_hours':self.convert_float_2time(rec.early_exit),
'tr_total_early_exit_hours':self.get_translation_field(rec,'early_exit'),
'tr_total_early_exit_hours':self.get_translation_field(rec, 'early_exit'),
'early_exit':rec.approve_exit_out,
'tr_early_exit':self.get_translation_field(rec,'approve_exit_out'),
'tr_early_exit':self.get_translation_field(rec, 'approve_exit_out'),
'total_permission_hours':self.convert_float_2time(rec.total_permission_hours),
'tr_total_permission_hours':self.get_translation_field(rec,'total_permission_hours'),
'tr_total_permission_hours':self.get_translation_field(rec, 'total_permission_hours'),
'permission':rec.approve_personal_permission,
'tr_permission':self.get_translation_field(rec,'approve_personal_permission'),
'tr_permission':self.get_translation_field(rec, 'approve_personal_permission'),
'total_mission_hours':self.convert_float_2time(rec.total_mission_hours),
'tr_total_mission_hours':self.get_translation_field(rec,'total_mission_hours'),
'tr_total_mission_hours':self.get_translation_field(rec, 'total_mission_hours'),
'mission':rec.is_official,
'tr_mission':self.get_translation_field(rec,'is_official'),
'tr_mission':self.get_translation_field(rec, 'is_official'),
'is_absent':rec.is_absent,
'tr_is_absent':self.get_translation_field(rec,'is_absent'),
'tr_is_absent':self.get_translation_field(rec, 'is_absent'),
'normal_leave':rec.normal_leave,
'tr_normal_leave':self.get_translation_field(rec,'normal_leave'),
'tr_normal_leave':self.get_translation_field(rec, 'normal_leave'),
'public_holiday':rec.public_holiday,
'tr_public_holiday':self.get_translation_field(rec,'public_holiday'),
'tr_public_holiday':self.get_translation_field(rec, 'public_holiday'),
}
li.append(attendance)
return http_helper.response(message="Data Found", data={'attendaces': li})
return http_helper.response(message="Data Found", data={'total_months':total_months, 'attendaces': li})
else:
return http_helper.response(message="Data not Found", data={'attendaces': li})
except (UserError, AccessError, ValidationError, Exception, Warning) as e:
http.request._cr.rollback()
error = str(e)
@ -328,6 +361,7 @@ class AttendanceController(http.Controller):
_logger.error(str(e))
message = validator.get_server_error(e, user)
return http_helper.errcode(code=403, message=message)
# Get shift
@http.route(['/rest_api/v2/shifts'], type='http', auth='none', csrf=False, methods=['GET'])
def get_shift(self, **kw):
@ -394,8 +428,8 @@ class AttendanceController(http.Controller):
if now > last:
diff = now - last
diff = diff.seconds / 60
zone = http.request.env['attendance.zone'].search([('employee_ids', 'in', employee.id)],limit=1)
zone_general = http.request.env['attendance.zone'].search([('general', '=', True)],limit=1)
zone = http.request.env['attendance.zone'].search([('employee_ids', 'in', employee.id)], limit=1)
zone_general = http.request.env['attendance.zone'].search([('general', '=', True)], limit=1)
auto = zone.auto_checkout or zone_general.auto_checkout or request.env.user.company_id.auto_checkout or 20
if diff >= auto:
attendance = http.request.env['attendance.attendance'].create({
@ -464,11 +498,14 @@ class AttendanceController(http.Controller):
'latitude':latitude,
})
def convert_float_2time(self,time):
def convert_float_2time(self, time):
td = timedelta(hours=time)
dt = datetime.min + td
time = "{:%H:%M}".format(dt)
return time
def get_translation_field(self,rec,field):
return request.env['ir.translation'].get_field_string(rec._name)[field]
def convert_float_total_time(self, time):
return '{0:02.0f}:{1:02.0f}'.format(*divmod(time * 60, 60))
def get_translation_field(self, rec, field):
return request.env['ir.translation'].get_field_string(rec._name)[field]

View File

@ -85,11 +85,11 @@ class AuthenticationController(http.Controller):
if not user:
return http_helper.errcode(code=400, message=_("You are not allowed to perform this operation. please check with one of your team admins"))
if not http_helper.is_authentic(user.login, body.get('new_password')):
if not http_helper.is_authentic(user.login, body.get('old_password')):
return http_helper.errcode(code=400, message='Invalid passwords')
res = request.env.user.sudo().write({
'password':str(body.get('old_password')).strip()
'password':str(body.get('new_password')).strip()
})
# # change_password(self, old_passwd, new_passwd)