parent
97569423e5
commit
23334f3cdf
|
|
@ -1,11 +1,11 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
{
|
||||
'name': 'HR Holiday Permission',
|
||||
'name': 'Hr Holiday Permission',
|
||||
'version': '1.0',
|
||||
'summary': """HR Holiday Permission""",
|
||||
'description': """HR Holiday Permission.
|
||||
'summary': """Hr Holiday Permission""",
|
||||
'description': """Hr Holiday Permission.
|
||||
This module gives Feature of deduct Permissions from holidays""",
|
||||
'category': 'HR-Odex',
|
||||
'category': 'Odex25-HR/Odex25-HR',
|
||||
'author': 'Expert Co. Ltd.',
|
||||
'website': 'http://exp-sa.com',
|
||||
'depends': ['hr_holidays_public', 'employee_requests'],
|
||||
|
|
|
|||
|
|
@ -17,9 +17,8 @@ msgstr ""
|
|||
|
||||
#. module: hr_permission_holidays
|
||||
#: model:ir.model.fields,field_description:hr_permission_holidays.field_hr_personal_permission__deduct_from_holiday
|
||||
#: model_terms:ir.ui.view,arch_db:hr_permission_holidays.hr_view_tree_inherit_permissions_holiday
|
||||
msgid "Half Day Off"
|
||||
msgstr "نصف يوم من الإجازة السنوية"
|
||||
msgid "Deduct From Holiday"
|
||||
msgstr "الخصم من رصيد الاجازة"
|
||||
|
||||
#. module: hr_permission_holidays
|
||||
#: model:ir.model.fields,field_description:hr_permission_holidays.field_hr_holidays__display_name
|
||||
|
|
@ -72,8 +71,8 @@ msgstr "رقم الإذن"
|
|||
|
||||
#. module: hr_permission_holidays
|
||||
#: model:ir.model.fields,field_description:hr_permission_holidays.field_resource_calendar__holiday_permission_deducted
|
||||
msgid "Number Permission Holiday"
|
||||
msgstr "عدد إستئذانات الاجازة"
|
||||
msgid "Permission to Deduct From holiday"
|
||||
msgstr "خصم الاذن من الاجازة"
|
||||
|
||||
#. module: hr_permission_holidays
|
||||
#: model:ir.model.fields,field_description:hr_permission_holidays.field_hr_holidays__permission_ids
|
||||
|
|
@ -82,8 +81,8 @@ msgstr "الاذونات"
|
|||
|
||||
#. module: hr_permission_holidays
|
||||
#: model:ir.model.fields,field_description:hr_permission_holidays.field_hr_holidays_status__permission_annual_holiday
|
||||
msgid "Permissions Half Day Off"
|
||||
msgstr "نصف يوم من الإجازة السنوية"
|
||||
msgid "Permissions Deduct From Holiday"
|
||||
msgstr "خصم الإذن من الاجازة السنوية"
|
||||
|
||||
#. module: hr_permission_holidays
|
||||
#: model:ir.model,name:hr_permission_holidays.model_resource_calendar
|
||||
|
|
@ -96,35 +95,31 @@ msgstr "فترة عمل المورد"
|
|||
msgid "Sorry You Have No annual Leave To Deduct Permission"
|
||||
msgstr "عذرا ليس هنالك اجازة سنوية لخصم الاذن"
|
||||
|
||||
#. module: hr_permission_holidays
|
||||
#: code:addons/hr_permission_holidays/models/permission.py:0
|
||||
#, python-format
|
||||
msgid "Sorry You Have Used All Your Permission In This Day you have one permission per a Day"
|
||||
msgstr "لايمكن طلب اذن مره أخرى في نفس اليوم"
|
||||
|
||||
#. module: hr_permission_holidays
|
||||
#: code:addons/hr_permission_holidays/models/permission.py:0
|
||||
#, python-format
|
||||
msgid "Sorry You Have Used All Your Permission Hours In This Month"
|
||||
msgstr "تم استخدام كل ساعات الإستئذانات المسموح بها خلال هذا الشهر"
|
||||
msgstr "تم استخدام كل الاذونات المسموح بها خلال هذا الشهر"
|
||||
|
||||
#. module: hr_permission_holidays
|
||||
#: code:addons/hr_permission_holidays/models/permission.py:0
|
||||
#, python-format
|
||||
msgid "This Duration Must Be Greater Than Zero"
|
||||
msgstr "فترة الاذن يجب ان تكون اكبر من الصفر"
|
||||
msgid ""
|
||||
"Sorry You Have Used All Your Permission In This Day you have one permission "
|
||||
"per a Day"
|
||||
msgstr "عذرًا ، لقد استخدمت كل الأذونات الخاصة بك في هذا اليوم ، لديك إذن واحد لكل يوم"
|
||||
|
||||
#. module: hr_permission_holidays
|
||||
#: code:addons/hr_permission_holidays/models/permission.py:0
|
||||
#, python-format
|
||||
msgid "Sorry You Have Used All Your Permission To Half Day Off"
|
||||
msgid "Sorry You Have Used All Your Permission To Deduct From Holidays"
|
||||
msgstr "تم استخدام كل الاذونات المسموح بخصمها من الاجازة السنوية!"
|
||||
|
||||
#. module: hr_permission_holidays
|
||||
#: code:addons/hr_permission_holidays/models/permission.py:0
|
||||
#, python-format
|
||||
msgid "Sorry You Need To use Basic Permission Before Use Holidays"
|
||||
msgstr "عذرا لايمكنك طلب خصم من اجازة وانت لديك رصيد إذن غير مستخدم "
|
||||
msgstr "عذرا لايمكنك طلب خصم من اجازة وانت ﻻتمتلك رصيد إذن غير مستخدم"
|
||||
|
||||
#. module: hr_permission_holidays
|
||||
#: code:addons/hr_permission_holidays/models/permission.py:0
|
||||
|
|
@ -136,7 +131,7 @@ msgstr "لايوجد رصيد اجازة سنوية للخصم منه"
|
|||
#. module: hr_permission_holidays
|
||||
#: model:ir.model.fields,help:hr_permission_holidays.field_resource_calendar__holiday_permission_deducted
|
||||
msgid "The Number of permission deducted From The Annual Holiday balance"
|
||||
msgstr "عدد مرات الإستئذانات التى يتم خصمها من رصيد الاجازة السنوية"
|
||||
msgstr "عدد الإذن المقتطع من رصيد الإجازة السنوية"
|
||||
|
||||
#. module: hr_permission_holidays
|
||||
#: model:ir.model.fields,help:hr_permission_holidays.field_hr_personal_permission__permission_number
|
||||
|
|
@ -146,34 +141,30 @@ msgstr "إذن العدد المتبقي من الساعات هذا الشهر"
|
|||
#. module: hr_permission_holidays
|
||||
#: code:addons/hr_permission_holidays/models/permission.py:0
|
||||
#, python-format
|
||||
msgid "This Duration must be Greater than or equal to the Permission Limit"
|
||||
msgstr "فترة الاذن يجب ان تكون اكبر من او يساوي فترة الإستئذانات المسموح بها"
|
||||
msgid "This Duration Must Be Greater Than Zero"
|
||||
msgstr "يجب أن تكون هذه المدة أكبر من الصفر"
|
||||
|
||||
#. module: hr_permission_holidays
|
||||
#: code:addons/hr_permission_holidays/models/permission.py:0
|
||||
#, python-format
|
||||
msgid "This Duration not Allowed it must be Less Than or equal Permission Hours in Month"
|
||||
msgstr "فترة الإذن يجب ان تكون اقل من او يساوي فترة الإستئذانات المسموح بها خلال الشهر"
|
||||
msgid "This Duration must be less than or equal to the Permission Limit"
|
||||
msgstr "يجب أن تكون هذه المدة أقل من أو تساوي حد الإذن"
|
||||
|
||||
#. module: hr_permission_holidays
|
||||
#: code:addons/hr_permission_holidays/models/permission.py:0
|
||||
#, python-format
|
||||
msgid ""
|
||||
"This Duration not Allowed it must be Less Than or equal Permission Hours in "
|
||||
"Month"
|
||||
msgstr "هذه المدة غير مسموح بها يجب أن تكون أقل من أو تساوي ساعات الإذن في الشهر"
|
||||
|
||||
#. module: hr_permission_holidays
|
||||
#: code:addons/hr_permission_holidays/models/permission.py:0
|
||||
#, python-format
|
||||
msgid "You can not Request Permission The Employee have Not First Hiring Date"
|
||||
msgstr "لا يمكنك طلب إستئذان لموظف وليس لديه تاريخ مباشرة عمل"
|
||||
msgstr "لا يمكنك طلب الإذن ليس للموظف تاريخ التعيين الأول"
|
||||
|
||||
#. module: hr_permission_holidays
|
||||
#: model:ir.model,name:hr_permission_holidays.model_hr_personal_permission
|
||||
msgid "hr.personal.permission"
|
||||
msgstr "الإستئذانات"
|
||||
|
||||
#. module: hr_permission_holidays
|
||||
#: code:addons/hr_permission_holidays/models/permission.py:0
|
||||
#, python-format
|
||||
msgid "The Number Of Hours should Be 4 Hours For the Half Day Leave"
|
||||
msgstr "يجب ان تكون ساعات طلب نصف يوم من الاجازة السنوية 4 ساعات"
|
||||
|
||||
#. module: hr_permission_holidays
|
||||
#: code:addons/hr_permission_holidays/models/permission.py:0
|
||||
#, python-format
|
||||
msgid "Sorry, Must Be a Half Day Period Within Working Hours"
|
||||
msgstr "يجب ان تكون فترة نصف يوم خلال ساعات العمل"
|
||||
msgstr ""
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ from odoo import fields, models
|
|||
class HrHolidaysStatus(models.Model):
|
||||
_inherit = 'hr.holidays.status'
|
||||
|
||||
permission_annual_holiday = fields.Boolean(string="Permissions Half Day Off")
|
||||
permission_annual_holiday = fields.Boolean(string="Permissions Deduct From Holiday")
|
||||
|
||||
|
||||
class HRHolidays(models.Model):
|
||||
|
|
|
|||
|
|
@ -1,28 +1,19 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
|
||||
from odoo import models, fields, api,_
|
||||
from datetime import datetime,timedelta
|
||||
import time
|
||||
from odoo.tools import DEFAULT_SERVER_DATETIME_FORMAT,DEFAULT_SERVER_DATE_FORMAT
|
||||
from odoo import models, fields, api, _
|
||||
from datetime import datetime
|
||||
from odoo.tools import DEFAULT_SERVER_DATETIME_FORMAT
|
||||
from odoo.exceptions import ValidationError
|
||||
|
||||
|
||||
class HrPersonalPermission(models.Model):
|
||||
_inherit = 'hr.personal.permission'
|
||||
|
||||
deduct_from_holiday = fields.Boolean(string="Half Day Off")
|
||||
holiday = fields.Many2one('hr.holidays',string="Holiday")
|
||||
deduct_from_holiday = fields.Boolean(string="Deduct From Holiday")
|
||||
holiday = fields.Many2one('hr.holidays', string="Holiday")
|
||||
permission_amount = fields.Float(string="Permission Amount")
|
||||
permission_number = fields.Float(compute="get_permission_number", store=True)
|
||||
|
||||
|
||||
def send(self):
|
||||
res = super(HrPersonalPermission,self).send()
|
||||
self.get_permission_number()
|
||||
#self._get_date_constrains(employee_permissions)
|
||||
self.permission_number_decrement()
|
||||
return res
|
||||
|
||||
def get_date_to_constrains_value(self):
|
||||
current_date = datetime.strptime(str(self.date_to), DEFAULT_SERVER_DATETIME_FORMAT)
|
||||
current_month = datetime.strptime(str(self.date_to), DEFAULT_SERVER_DATETIME_FORMAT).month
|
||||
|
|
@ -32,8 +23,7 @@ class HrPersonalPermission(models.Model):
|
|||
date_to = current_date.strftime('%Y-{0}-31'.format(current_month))
|
||||
employee_permissions = self.search([
|
||||
('employee_id', '=', self.employee_id.id),
|
||||
#('state', '=', 'approve'),
|
||||
('state', 'in', ('send','approve') ),
|
||||
('state', '=', 'approve'),
|
||||
('date_from', '>=', date_from),
|
||||
('date_to', '<=', date_to)])
|
||||
return date_from, date_to, employee_permissions
|
||||
|
|
@ -43,67 +33,55 @@ class HrPersonalPermission(models.Model):
|
|||
for rec in self:
|
||||
if rec.date_to:
|
||||
date_from, date_to, employee_permissions = rec.get_date_to_constrains_value()
|
||||
basic = employee_permissions.filtered(lambda r:r.deduct_from_holiday == False)
|
||||
basic = employee_permissions.filtered(lambda r: r.deduct_from_holiday == False)
|
||||
calender = rec.employee_id.resource_calendar_id
|
||||
all_perission = 0.0
|
||||
for item in employee_permissions:
|
||||
all_perission += item.duration
|
||||
|
||||
for item in employee_permissions.filtered(lambda r: r.id != self.id):
|
||||
if item.deduct_from_holiday == False:
|
||||
all_perission += item.duration
|
||||
|
||||
if calender.permission_number - all_perission >= 0:
|
||||
rec.permission_number = round(calender.permission_number - all_perission,2)
|
||||
|
||||
if calender.permission_number - all_perission > 0:
|
||||
rec.permission_number = round(calender.permission_number - all_perission, 2)
|
||||
|
||||
# @api.onchange('date_to', 'date_from', 'employee_id','deduct_from_holiday')
|
||||
@api.constrains('date_to', 'date_from', 'employee_id', 'deduct_from_holiday','state')
|
||||
@api.constrains('date_to', 'date_from', 'employee_id', 'deduct_from_holiday')
|
||||
def permission_number_decrement(self):
|
||||
for rec in self:
|
||||
if not rec.employee_id.first_hiring_date:
|
||||
raise ValidationError(_('You can not Request Permission The Employee have Not First Hiring Date'))
|
||||
if rec.date_to:
|
||||
rec.check_holiday_mission()
|
||||
|
||||
date_from, date_to, employee_permissions = rec.get_date_to_constrains_value()
|
||||
calender = rec.employee_id.resource_calendar_id
|
||||
day_hours = calender.work_hour
|
||||
rec.permission_amount = rec.duration/day_hours
|
||||
basic = employee_permissions.filtered(lambda r:r.deduct_from_holiday == False)
|
||||
rec.permission_amount = rec.duration / day_hours
|
||||
basic = employee_permissions.filtered(lambda r: r.deduct_from_holiday == False)
|
||||
|
||||
for item in employee_permissions.filtered(lambda r:r.id != self.id):
|
||||
|
||||
if item.date_to and rec.date_to:
|
||||
permission_date1 = datetime.strptime(str(item.date_to),DEFAULT_SERVER_DATETIME_FORMAT).date()
|
||||
date_to_value1 = datetime.strptime(str(rec.date_to), DEFAULT_SERVER_DATETIME_FORMAT).date()
|
||||
if permission_date1 == date_to_value1:
|
||||
raise ValidationError(_('Sorry You Have Used All Your Permission In This Day you have one permission per a Day'))
|
||||
|
||||
employee_permissions_holiday = employee_permissions.filtered(lambda r: r.deduct_from_holiday == True and r.id != self.id)
|
||||
employee_permissions_holiday = employee_permissions.filtered(lambda r: r.deduct_from_holiday == True)
|
||||
if rec.deduct_from_holiday:
|
||||
if rec.permission_number >= 0.0:
|
||||
if rec.permission_number <= 0.0:
|
||||
rec._get_date_constrains(employee_permissions_holiday)
|
||||
annual = rec.env['hr.holidays.status'].search([('leave_type', '=', 'annual')
|
||||
,('permission_annual_holiday', '=',True),])
|
||||
annual = rec.env['hr.holidays.status'].search(
|
||||
[('leave_type', '=', 'annual'), ('permission_annual_holiday', '=', True)])
|
||||
for itm in annual:
|
||||
if rec.employee_id and itm:
|
||||
holiday = rec.env['hr.holidays'].search([('employee_id', '=', rec.employee_id.id),('type', '=', 'add'),
|
||||
('holiday_status_id', '=', itm.id),
|
||||
('check_allocation_view', '=', 'balance')
|
||||
], order='id desc', limit=1)
|
||||
if holiday:
|
||||
holiday = rec.env['hr.holidays'].search(
|
||||
[('employee_id', '=', rec.employee_id.id), ('type', '=', 'add'),
|
||||
('holiday_status_id', '=', itm.id),
|
||||
('check_allocation_view', '=', 'balance')
|
||||
], order='id desc', limit=1)
|
||||
if holiday:
|
||||
rec.holiday = holiday.id
|
||||
balance = holiday.remaining_leaves or 0.0
|
||||
if len(employee_permissions_holiday) < calender.holiday_permission_deducted:
|
||||
if balance < rec.permission_amount:
|
||||
raise ValidationError(_('Sorry you Have No leave balance'))
|
||||
else:
|
||||
raise ValidationError(_
|
||||
('Sorry You Have Used All Your Permission To Half Day Off'))
|
||||
|
||||
raise ValidationError(
|
||||
_('Sorry You Have Used All Your Permission To Deduct From Holidays'))
|
||||
else:
|
||||
raise ValidationError(_('Sorry You Have No annual Leave To Deduct Permission'))
|
||||
#else:
|
||||
#raise ValidationError(_('Sorry You Need To use Basic Permission Before Use Holidays'))
|
||||
else:
|
||||
raise ValidationError(_('Sorry You Need To use Basic Permission Before Use Holidays'))
|
||||
else:
|
||||
rec._get_date_constrains(basic)
|
||||
|
||||
|
|
@ -121,15 +99,14 @@ class HrPersonalPermission(models.Model):
|
|||
self.holiday.leaves_taken -= self.permission_amount
|
||||
|
||||
def approve(self):
|
||||
res = super(HrPersonalPermission,self).approve()
|
||||
res = super(HrPersonalPermission, self).approve()
|
||||
self.leave_balance_process()
|
||||
self.get_permission_number()
|
||||
return res
|
||||
|
||||
def draft_state(self):
|
||||
if self.state == 'approve' and self.deduct_from_holiday:
|
||||
self.cancel_leave_balance_process()
|
||||
res = super(HrPersonalPermission,self).draft_state()
|
||||
res = super(HrPersonalPermission, self).draft_state()
|
||||
return res
|
||||
|
||||
def _get_date_constrains(self, employee_permissions):
|
||||
|
|
@ -149,41 +126,19 @@ class HrPersonalPermission(models.Model):
|
|||
days = (end_date - start_date_value).days
|
||||
seconds_diff = (end_date - start_date_value).seconds
|
||||
item.duration = (days * 24) + seconds_diff / 3600
|
||||
|
||||
all_perission=0
|
||||
all_perission = 0
|
||||
for rec in employee_permissions:
|
||||
if rec.deduct_from_holiday == False:
|
||||
all_perission += rec.duration
|
||||
all_perission += rec.duration
|
||||
|
||||
if number_of_per < all_perission :
|
||||
if number_of_per < all_perission:
|
||||
raise ValidationError(_('Sorry You Have Used All Your Permission Hours In This Month'))
|
||||
|
||||
if item.duration <= 0.0:
|
||||
raise ValidationError(_('This Duration Must Be Greater Than Zero'))
|
||||
|
||||
if item.duration < item.balance and item.duration < item.permission_number:
|
||||
raise ValidationError(_('This Duration must be Greater than or equal to the Permission Limit'))
|
||||
if item.duration < item.balance:
|
||||
raise ValidationError(_('This Duration must be less than or equal to the Permission Limit'))
|
||||
|
||||
if item.duration > item.permission_number and item.deduct_from_holiday== False:
|
||||
raise ValidationError(_('This Duration not Allowed it must be Less Than or equal Permission Hours in Month'))
|
||||
|
||||
#################### Half day holiday 4 hours ##########
|
||||
if item.deduct_from_holiday:
|
||||
date_from = datetime.strptime(str(item.date_from), "%Y-%m-%d %H:%M:%S")
|
||||
date_to = datetime.strptime(str(item.date_to), "%Y-%m-%d %H:%M:%S")
|
||||
date_from_time = (date_from + timedelta(hours=3)).time()
|
||||
date_to_time = (date_to + timedelta(hours=3)).time()
|
||||
hour_from = date_from_time.hour + date_from_time.minute / 60.0
|
||||
hour_to = date_to_time.hour + date_to_time.minute / 60.0
|
||||
#print('>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>',hour_from,hour_to)
|
||||
|
||||
if item.duration !=4:
|
||||
raise ValidationError(_('The Number Of Hours should Be 4 Hours For the Half Day Leave'))
|
||||
|
||||
if item.employee_id.contract_id.working_hours.is_full_day== True:
|
||||
hour_sign = item.employee_id.contract_id.working_hours.full_min_sign_in
|
||||
hour_sign_out = item.employee_id.contract_id.working_hours.full_max_sign_out
|
||||
#print('######################################',hour_sign,hour_sign_out)
|
||||
if hour_from < hour_sign or hour_to > hour_sign_out:
|
||||
raise ValidationError(_('Sorry, Must Be a Half Day Period Within Working Hours'))
|
||||
|
||||
if item.duration > item.permission_number and not item.deduct_from_holiday:
|
||||
raise ValidationError(
|
||||
_('This Duration not Allowed it must be Less Than or equal Permission Hours in Month'))
|
||||
|
|
|
|||
|
|
@ -6,5 +6,5 @@ from odoo import models, fields
|
|||
class HrAttendances(models.Model):
|
||||
_inherit = 'resource.calendar'
|
||||
|
||||
holiday_permission_deducted = fields.Integer(string="Number Permission Holiday",
|
||||
holiday_permission_deducted = fields.Integer(string="Permission to Deduct From holiday",
|
||||
help='The Number of permission deducted From The Annual Holiday balance')
|
||||
|
|
|
|||
|
|
@ -8,32 +8,10 @@
|
|||
<field name="priority">100</field>
|
||||
<field name="arch" type="xml">
|
||||
<field name="department_id" position="after">
|
||||
<field name="deduct_from_holiday" attrs="{'readonly':[('state','!=','draft')]}"/>
|
||||
<field name="deduct_from_holiday" attrs="{'readonly':[('state','!=','draft')],'invisible':[('permission_number','!=',0.00)]}"/>
|
||||
<field name="holiday" invisible="1"/>
|
||||
<field name="permission_amount" invisible="1"/>
|
||||
</field>
|
||||
|
||||
<xpath expr="//field[@name='balance']" position="attributes">
|
||||
<attribute name="attrs">{'invisible':[('deduct_from_holiday','=',True)]}</attribute>
|
||||
</xpath>
|
||||
|
||||
<xpath expr="//field[@name='permission_number']" position="attributes">
|
||||
<attribute name="attrs">{'invisible':[('deduct_from_holiday','=',True)]}</attribute>
|
||||
</xpath>
|
||||
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record model="ir.ui.view" id="hr_view_tree_inherit_permissions_holiday">
|
||||
<field name="name">Employee personal permission</field>
|
||||
<field name="model">hr.personal.permission</field>
|
||||
<field name="inherit_id" ref="employee_requests.employee_personal_permission_tree_view"/>
|
||||
<field name="arch" type="xml">
|
||||
|
||||
<xpath expr="//field[@name='duration']" position="after">
|
||||
<field name="deduct_from_holiday" string="Half Day Off"/>
|
||||
</xpath>
|
||||
|
||||
</field>
|
||||
</record>
|
||||
|
||||
|
|
|
|||
|
|
@ -27,4 +27,4 @@
|
|||
</field>
|
||||
</record>
|
||||
</data>
|
||||
</odoo>
|
||||
</odoo>
|
||||
Loading…
Reference in New Issue