From 13471b6400cfccedbb5a074adc2d31f59ac4d041 Mon Sep 17 00:00:00 2001 From: Bakry Date: Mon, 27 Jan 2025 12:37:38 +0300 Subject: [PATCH] fix alternative days holiday --- .../attendances/models/hr_attendance_register.py | 12 ++++++++---- .../employee_requests/models/hr_clearance_form.py | 4 ++-- odex25_hr/hr_holidays_public/i18n/ar_001.po | 14 +++++++++++++- odex25_hr/hr_holidays_public/models/hr_holidays.py | 4 ++-- .../models/hr_holidays_status.py | 7 +++++++ .../views/hr_holidays_status_views.xml | 1 + 6 files changed, 33 insertions(+), 9 deletions(-) diff --git a/odex25_hr/attendances/models/hr_attendance_register.py b/odex25_hr/attendances/models/hr_attendance_register.py index 830a467c6..ef4f0a9f5 100644 --- a/odex25_hr/attendances/models/hr_attendance_register.py +++ b/odex25_hr/attendances/models/hr_attendance_register.py @@ -138,7 +138,7 @@ class HrAttendanceRegister(models.Model): 'action_date': rec.action_date.date(), 'action_type': 'manual', }) - rec.call_cron_function() + rec.call_cron_function() rec.state = "hr_manager" @@ -160,13 +160,17 @@ class HrAttendanceRegister(models.Model): for attendance in attendances: if attendance.name == item.action_date: attendance.unlink() - item.call_cron_function() + item.call_cron_function() item.state = "draft" def call_cron_function(self): - date = datetime.strptime(str(self.action_date), "%Y-%m-%d %H:%M:%S") - self.env['hr.attendance.transaction'].process_attendance_scheduler_queue(self.action_date, self.employee_id) + for rec in self: + if rec.all_employees== False: + self.env['hr.attendance.transaction'].process_attendance_scheduler_queue(rec.action_date, rec.employee_id) + else: + for emp in rec.employee_ids: + self.env['hr.attendance.transaction'].process_attendance_scheduler_queue(rec.action_date, emp) def refused(self): self.state = "refused" diff --git a/odex25_hr/employee_requests/models/hr_clearance_form.py b/odex25_hr/employee_requests/models/hr_clearance_form.py index a9095b668..3b45b1d39 100644 --- a/odex25_hr/employee_requests/models/hr_clearance_form.py +++ b/odex25_hr/employee_requests/models/hr_clearance_form.py @@ -39,8 +39,8 @@ class HrClearanceForm(models.Model): ("submit", _("Waiting Direct Manager")), ("direct_manager", _("Waiting IT Department")), ("info_system", _("Waiting Cyber ​​Security")), - ('cyber_security', _('Waiting Admin Affairs')), - ('admin_manager', _('Waiting Finance Approvals')), + ("cyber_security", _("Waiting Admin Affairs")), + ("admin_manager", _("Waiting Finance Approvals")), ("wait", _("Waiting HR Manager")), ("services_manager", _("Waiting Services Manager")), ("done", _("Approved")), diff --git a/odex25_hr/hr_holidays_public/i18n/ar_001.po b/odex25_hr/hr_holidays_public/i18n/ar_001.po index b85f46064..adec0ba70 100644 --- a/odex25_hr/hr_holidays_public/i18n/ar_001.po +++ b/odex25_hr/hr_holidays_public/i18n/ar_001.po @@ -229,13 +229,25 @@ msgstr "السماح لتجاوز الحد" #. module: hr_holidays_public #: model:ir.model.fields,field_description:hr_holidays_public.field_hr_holidays_status__alternative_chick msgid "Alternative Chick" -msgstr "" +msgstr "تتطلب موظف بديل" + +#. module: hr_holidays_public +#: model_terms:ir.ui.view,arch_db:hr_holidays_public.edit_holiday_status_form +#: model:ir.model.fields,field_description:hr_holidays_public.field_hr_holidays_status__alternative_days +msgid "Alternative Days" +msgstr "أيام للبديل" #. module: hr_holidays_public #: model:ir.model.fields,field_description:hr_holidays_public.field_return_from_leave__alternative_emp_id msgid "Alternative Employee" msgstr "الموظف البديل" +#. module: hr_holidays_public +#: code:addons/hr_holidays_public/models/hr_holidays_status.py:0 +#, python-format +msgid "Sorry, The Alternative Employee Days Must Be Greater Than One Day." +msgstr "عذرًا، يجب أن تكون أيام الموظف البديل أكبر من يوم واحد" + #. module: hr_holidays_public #: model_terms:ir.ui.view,arch_db:hr_holidays_public.edit_holiday_status_form msgid "Alternative Required?" diff --git a/odex25_hr/hr_holidays_public/models/hr_holidays.py b/odex25_hr/hr_holidays_public/models/hr_holidays.py index 18cfb5adc..7204645cb 100644 --- a/odex25_hr/hr_holidays_public/models/hr_holidays.py +++ b/odex25_hr/hr_holidays_public/models/hr_holidays.py @@ -1382,7 +1382,7 @@ class HRHolidays(models.Model): self._compute_leave_balance() self._remove_followers_holiday() if not self.replace_by and self.type == 'remove': - if self.holiday_status_id.alternative_chick == True: + if self.holiday_status_id.alternative_chick == True and self.number_of_days_temp >= self.holiday_status_id.alternative_days: raise exceptions.Warning(_('Select employee Replacement before The approve holiday Request')) if self.delegate_acc == True: raise exceptions.Warning(_('The replacement Employee Must be entered To Giving him Access')) @@ -1420,7 +1420,7 @@ class HRHolidays(models.Model): for item in self: item._remove_followers_holiday() if not item.replace_by and item.type == 'remove': - if item.holiday_status_id.alternative_chick == True: + if item.holiday_status_id.alternative_chick == True and item.number_of_days_temp >= item.holiday_status_id.alternative_days: raise exceptions.Warning(_('Select employee Replacement before The approve holiday Request')) if item.delegate_acc == True: raise exceptions.Warning(_('The replacement Employee Must be entered To Giving him Access')) diff --git a/odex25_hr/hr_holidays_public/models/hr_holidays_status.py b/odex25_hr/hr_holidays_public/models/hr_holidays_status.py index c103c7657..d4bc7530c 100644 --- a/odex25_hr/hr_holidays_public/models/hr_holidays_status.py +++ b/odex25_hr/hr_holidays_public/models/hr_holidays_status.py @@ -52,6 +52,7 @@ class HrHolidaysStatus(models.Model): mission_chick = fields.Boolean(tracking=True) attach_chick = fields.Boolean(tracking=True) alternative_chick = fields.Boolean(default=True,tracking=True) + alternative_days = fields.Integer(string='Alternative Days') limit = fields.Boolean(tracking=True) '''color_name = fields.Selection(selection=[('red', _('Red')), ('blue', _('Blue')), @@ -187,6 +188,12 @@ class HrHolidaysStatus(models.Model): "Sorry past years balance can not be greater than " "allowed holiday years balance to be carried to next years") + @api.constrains('alternative_days', 'alternative_chick') + def check_alternative_days(self): + for rec in self: + if rec.alternative_chick==True and rec.alternative_days <= 0: + raise ValidationError(_("Sorry, The Alternative Employee Days Must Be Greater Than One Day.")) + class CalenderEventType(models.Model): _name = 'calender.event.type' diff --git a/odex25_hr/hr_holidays_public/views/hr_holidays_status_views.xml b/odex25_hr/hr_holidays_public/views/hr_holidays_status_views.xml index 141918688..499543c9e 100644 --- a/odex25_hr/hr_holidays_public/views/hr_holidays_status_views.xml +++ b/odex25_hr/hr_holidays_public/views/hr_holidays_status_views.xml @@ -30,6 +30,7 @@ +