UPDATE hr_holidays_public

This commit is contained in:
manar 2025-01-20 13:31:01 +02:00
parent 54ff050032
commit 10f4c2977e
3 changed files with 63 additions and 18 deletions

View File

@ -4,10 +4,10 @@
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 14.0\n"
"Project-Id-Version: Odoo Server 14.0-20231205\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2024-12-03 11:57+0000\n"
"PO-Revision-Date: 2024-12-03 11:57+0000\n"
"POT-Creation-Date: 2025-01-20 11:12+0000\n"
"PO-Revision-Date: 2025-01-20 11:12+0000\n"
"Last-Translator: \n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
@ -94,6 +94,11 @@ msgstr "بداية الإجازة غير المدفوعة للموظف%s"
msgid "12 Months"
msgstr "12 شهر"
#. module: hr_holidays_public
#: model:ir.model.fields.selection,name:hr_holidays_public.selection__hr_holidays_status__contract_duration__12month
msgid "12 شهر"
msgstr ""
#. module: hr_holidays_public
#: code:addons/hr_holidays_public/models/hr_holidays_status.py:0
#: model:ir.model.fields.selection,name:hr_holidays_public.selection__hr_holidays_status__contract_duration__24month
@ -101,6 +106,11 @@ msgstr "12 شهر"
msgid "24 Months"
msgstr "24 شهر"
#. module: hr_holidays_public
#: model:ir.model.fields.selection,name:hr_holidays_public.selection__hr_holidays_status__contract_duration__24month
msgid "24 شهر"
msgstr ""
#. module: hr_holidays_public
#: model_terms:ir.ui.view,arch_db:hr_holidays_public.all_leave_report_template
#: model_terms:ir.ui.view,arch_db:hr_holidays_public.specified_leave_report_template
@ -407,6 +417,7 @@ msgstr "تقويم سنوي"
#. module: hr_holidays_public
#: code:addons/hr_holidays_public/models/hr_holidays.py:0
#: model:ir.model.fields.selection,name:hr_holidays_public.selection__hr_holidays__state__cancel
#: model:ir.model.fields.selection,name:hr_holidays_public.selection__leave_cancellation__cancellation_type__cancel
#: model_terms:ir.ui.view,arch_db:hr_holidays_public.holidays_public_next_year_wizard_view
#: model_terms:ir.ui.view,arch_db:hr_holidays_public.pubic_leave_report_wizard_view
#, python-format
@ -419,6 +430,11 @@ msgstr "إلغاء"
msgid "Canceled Duration"
msgstr "المدة الملغاة"
#. module: hr_holidays_public
#: model:ir.model.fields,field_description:hr_holidays_public.field_leave_cancellation__cancellation_type
msgid "Cancellation Type"
msgstr "النوع"
#. module: hr_holidays_public
#: model:ir.model.fields,field_description:hr_holidays_public.field_leave_cancellation__cause
#: model:ir.model.fields,field_description:hr_holidays_public.field_return_from_leave__cause
@ -574,6 +590,11 @@ msgstr "رصيد الإجازة السنوية الحالية"
msgid "Current contract of the employee"
msgstr "عقد الموظف الحالي "
#. module: hr_holidays_public
#: model:ir.model.fields.selection,name:hr_holidays_public.selection__leave_cancellation__cancellation_type__cut
msgid "Cut"
msgstr "قطع"
#. module: hr_holidays_public
#: model:ir.model.fields.selection,name:hr_holidays_public.selection__hr_holidays_status__balance_type__daily
msgid "Daily"
@ -1015,6 +1036,11 @@ msgstr "أنثى"
msgid "File content"
msgstr "محتوى الملف"
#. module: hr_holidays_public
#: model:ir.model.fields,field_description:hr_holidays_public.field_hr_holidays__hiring_date
msgid "First Hiring Date"
msgstr ""
#. module: hr_holidays_public
#: model:ir.model.fields,field_description:hr_holidays_public.field_buy_vacation__message_follower_ids
#: model:ir.model.fields,field_description:hr_holidays_public.field_hr_holiday_officials__message_follower_ids
@ -1100,7 +1126,7 @@ msgstr "من موظف آخر"
#: code:addons/hr_holidays_public/wizards/holiday_public_leave_report_wiz.py:0
#, python-format
msgid "From date"
msgstr ""
msgstr "من تاريخ"
#. module: hr_holidays_public
#: model:ir.model.fields,field_description:hr_holidays_public.field_hr_holidays_status__gender
@ -1573,13 +1599,13 @@ msgstr "إلغاء الاجازة"
#: model:ir.ui.menu,name:hr_holidays_public.leave_cancellation
#: model_terms:ir.ui.view,arch_db:hr_holidays_public.leave_cancellation_tree_view
msgid "Leave Cancellation"
msgstr "قطع الإجــازات"
msgstr "إلغاء/قطع الاجازات"
#. module: hr_holidays_public
#: model:ir.model.fields,field_description:hr_holidays_public.field_leave_cancellation__leave_cancellation_date
#: model_terms:ir.ui.view,arch_db:hr_holidays_public.leave_cancellation_form_view
msgid "Leave Cancellation Date"
msgstr "نهاية تاريخ قطع الاجازة"
msgstr "نهاية تاريخ إلغاء/قطع الاجازة"
#. module: hr_holidays_public
#: model:ir.actions.report,name:hr_holidays_public.public_leave_cost_action_report
@ -2631,7 +2657,7 @@ msgid ""
"If you plan for an early return kindly apply for leave cancellation."
msgstr ""
"عفواً هذه الإجازة تنتهي في %s.\n"
"اذا كنت تخطط للرجوع المبكر من الإجازة قم بتقديم طلب قطع إجازة"
"اذا كنت تخطط للرجوع المبكر من الإجازة قم بتقديم طلب إلغاء او قطع إجازة"
#. module: hr_holidays_public
#: code:addons/hr_holidays_public/models/hr_holidays_status.py:0
@ -2951,7 +2977,7 @@ msgstr "الى تاريخ"
#: code:addons/hr_holidays_public/wizards/holiday_public_leave_report_wiz.py:0
#, python-format
msgid "To date"
msgstr ""
msgstr "الى تاريخ"
#. module: hr_holidays_public
#: code:addons/hr_holidays_public/wizards/holiday_public_leave_report_wiz.py:0
@ -3282,7 +3308,7 @@ msgstr ""
msgid ""
"You can't set this request to draft as it's already have a cancel request\n"
"Please contact with your administrator"
msgstr "لا يمكنك إرجاع للمسودة لوجود طلب قطع لهذه الإجازة"
msgstr "لا يمكنك إرجاع للمسودة لوجود طلب الغاء/قطع لهذه الإجازة"
#. module: hr_holidays_public
#: code:addons/hr_holidays_public/models/hr_holidays.py:0

View File

@ -33,6 +33,10 @@ class LeaveCancellation(models.Model):
salary_rule_id = fields.Many2one('hr.salary.rule', string='Benefits/Discounts')
reconcile_leave = fields.Boolean(related='leave_request_id.reconcile_leave')
company_id = fields.Many2one('res.company', default=lambda self: self.env.company)
cancellation_type = fields.Selection([
('cut', 'Cut'),
('cancel', 'Cancel')
], string="Cancellation Type", default='cut', tracking=True)
def get_user_id(self):
employee_id = self.env['hr.employee'].search([('user_id', '=', self.env.uid)], limit=1)
@ -54,15 +58,21 @@ class LeaveCancellation(models.Model):
self.leave_date_to = self.leave_request_id.date_to
self.leave_cancellation_date = self.leave_request_id.date_to
@api.onchange('from_date', 'leave_cancellation_date', 'leave_date_from')
@api.onchange('from_date', 'leave_cancellation_date', 'leave_date_from', 'cancellation_type')
def onchange_dates(self):
for leave_req in self:
if self.from_date and self.leave_cancellation_date:
date_from = False
if self.from_date:
date_from = self.from_date
elif self.leave_date_from:
date_from = self.leave_date_from
if date_from and self.leave_cancellation_date:
if leave_req.leave_request_id.date_to:
if leave_req.leave_request_id.date_from:
leave_cancel_1 = dt.strptime(str(leave_req.leave_cancellation_date),
"%Y-%m-%d %H:%M:%S").date()
leave_from_1 = dt.strptime(str(leave_req.from_date), "%Y-%m-%d %H:%M:%S").date()
leave_from_1 = dt.strptime(str(date_from), "%Y-%m-%d %H:%M:%S").date()
leave_date_to_value = dt.strptime(str(leave_req.leave_request_id.date_to),
"%Y-%m-%d %H:%M:%S").date()
leave_date_from_value = dt.strptime(str(leave_req.leave_request_id.date_from),
@ -75,7 +85,7 @@ class LeaveCancellation(models.Model):
_('Duration of leave cancel must be between duration of request of leave '))
else:
if leave_req.leave_request_id.holiday_status_id.working_days:
from_dt = fields.Datetime.from_string(leave_req.from_date)
from_dt = fields.Datetime.from_string(date_from)
to_dt = fields.Datetime.from_string(leave_req.leave_cancellation_date)
time_delta = math.ceil((leave_cancel_1 - leave_from_1).days + float(
(leave_cancel_1 - leave_from_1).seconds) / 86400)
@ -93,7 +103,10 @@ class LeaveCancellation(models.Model):
time_delta = time_delta - 1
leave_req.duration_canceled = time_delta
else:
leave_req.duration_canceled = (leave_cancel_1 - leave_from_1).days
if leave_req.cancellation_type == 'cancel':
leave_req.duration_canceled = (leave_cancel_1 - leave_from_1).days + 1
else:
leave_req.duration_canceled = (leave_cancel_1 - leave_from_1).days
else:
leave_req.duration_canceled = 0
@ -159,7 +172,12 @@ class LeaveCancellation(models.Model):
def get_pure_holiday_days(self):
for item in self:
cancellation_dates = []
from_dt = dt.strptime(str(item.from_date), "%Y-%m-%d %H:%M:%S")
date_from = False
if item.from_date:
date_from = self.from_date
elif item.leave_date_from:
date_from = self.leave_date_from
from_dt = dt.strptime(str(date_from), "%Y-%m-%d %H:%M:%S")
for i in range((dt.strptime(str(item.leave_cancellation_date), "%Y-%m-%d %H:%M:%S") - from_dt).days):
cancellation_dates.append(from_dt.date() + timedelta(days=i))
cancelled_days = list(set(cancellation_dates))
@ -168,7 +186,7 @@ class LeaveCancellation(models.Model):
event_dates = []
for event in self.env['hr.holiday.officials'].search([('active', '=', True), ('state', '=', 'confirm'),
('date_from', '<=', item.leave_cancellation_date),
('date_to', '>=', item.from_date)]):
('date_to', '>=', date_from)]):
if event.religion and item.employee_id and item.employee_id.religion != event.religion:
continue
event_df = dt.strptime(str(event.date_from), '%Y-%m-%d').date()
@ -202,7 +220,7 @@ class LeaveCancellation(models.Model):
var_taken_leaves = balance.leaves_taken - cancelled_days
item.leave_request_id.date_to = item.from_date
item.leave_request_id.date_to = item.from_date or item.leave_date_from
item.leave_request_id.number_of_days_temp = item.leave_request_id.number_of_days_temp - cancelled_days
#item.leave_request_id.canceled_duration = item.leave_request_id.canceled_duration > 0 and \
# item.leave_request_id.canceled_duration + cancelled_days or \

View File

@ -40,13 +40,14 @@
<sheet>
<group>
<group>
<field name="cancellation_type" attrs="{'readonly':[('state','!=','draft')]}"/>
<field name="from_hr_department" string="Another Employee" attrs="{'readonly':[('state','!=','draft')]}"/>
<field name="employee_id" string="Employee"
attrs="{'readonly':['|',('from_hr_department' , '=' , False),('state','!=','draft')]}" required="1"/>
<field name="job_id" string="Job Title" readonly="1"/>
<field name="department_id" string="Department" readonly="1"/>
<field name="from_date" string="Last Leave Date" required="1" attrs="{'readonly':[('state','!=','draft')]}" widget="date"/>
<field name="from_date" string="Last Leave Date" attrs="{'readonly':[('state','!=','draft')], 'required': [('cancellation_type', '!=', 'cancel')], 'invisible': [('cancellation_type', '=', 'cancel')]}" widget="date"/>
<field name="leave_cancellation_date" required="1" string="Leave Cancellation Date" invisible="1"
attrs="{'readonly':[('state','!=','draft')]}" widget="date"/>
<field name="duration_canceled" string="Duration Canceled" readonly="1" force_save="1"/>