fix alternative days holiday

This commit is contained in:
Bakry 2025-01-27 12:37:38 +03:00
parent bec24d7c0c
commit 13471b6400
6 changed files with 33 additions and 9 deletions

View File

@ -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"

View File

@ -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")),

View File

@ -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?"

View File

@ -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'))

View File

@ -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'

View File

@ -30,6 +30,7 @@
<field name="mission_chick" string="Interference Mission/Training?"/>
<field name="attach_chick" string="Attachment Required?"/>
<field name="alternative_chick" string="Alternative Required?"/>
<field name="alternative_days" string="Alternative Days" attrs="{'invisible':[('alternative_chick','=',False)]}"/>
</group>
<group>
<field name="leave_type" string="Type Of Leave" required="1"/>