This commit is contained in:
Bakry 2024-10-15 16:43:13 +03:00
parent ad3d8a1eec
commit cf232650cc
2 changed files with 41 additions and 92 deletions

View File

@ -3177,35 +3177,20 @@ msgstr "لا يمكن اضافة تابع للموظف وهو في العقد ا
#. module: employee_requests
#: code:addons/employee_requests/models/hr_clearance_form.py:0
#, python-format
msgid ""
"You can not Employee Clearance \"%s\" employee custody not in state Return "
"Done for \"%s\" please reconcile it"
msgstr " لا يمكن إجراء خُلو طرف لـ %s لديه عُهد إدارية %s يجب إرجاع العهد اولآ"
msgid "Sorry, Can Not Clearance The Employee %s Has custody %s Not Return"
msgstr "للأسف, لايمكن إخلا طرف للموظف %s لديه عُهد إداريـــة %s يجب إرجاع العهد اولآ."
#. module: employee_requests
#: code:addons/employee_requests/models/hr_clearance_form.py:0
#, python-format
msgid ""
"You can not Employee Clearance \"%s\" employee petty cash payment not in "
"state Return Done for \"%s\" please reconcile it"
msgstr " لا يمكن إجراء خُلو طرف لـ %s لديه عُهد مالية %s يجب إرجاع العهد اولآ"
msgid "Sorry, Can Not Clearance The Employee %s Has Petty Cash %s Not Return"
msgstr "للأسف, لايمكن إخلا طرف للموظف %s لديه عُهد مــــالــية %s يجب إرجاع العهد اولآ."
#. module: employee_requests
#: code:addons/employee_requests/models/hr_clearance_form.py:0
#, python-format
msgid ""
"You can not Employee Clearance %s employee custody not in state Return Done "
"for %s please reconcile it"
msgstr ""
" لا يمكن إجراء خُلو طرف لـ %s لديه عُهد إدارية %s يجب إرجاع العهد اولآ"
#. module: employee_requests
#: code:addons/employee_requests/models/hr_clearance_form.py:0
#, python-format
msgid ""
"You can not Employee Clearance %s employee petty cash payment not in state "
"Return Done for %s please reconcile it"
msgstr " لا يمكن إجراء خُلو طرف لـ %s لديه عُهد مالية %s يجب إرجاع العهد اولآ"
msgid "Sorry, Can not Clearance The employee %s Has delegation vehicle %s Is Valid"
msgstr "للأسف, لايمكن إخلا طرف للموظف %s لديه تفويض على المركبة %s ساري."
#. module: employee_requests
#: code:addons/employee_requests/models/employee_department_jobs.py:0
@ -3927,12 +3912,3 @@ msgstr "لايمكن طلب عمل إضافي للموظف %s بقيمة عمل
msgid "You can not Request Overtime The Employee %s The Overtime Amount Zero"
msgstr "لايمكن طلب عمل إضافي للموظف %s بقيمة عمل إضافي صفر."
#. module: employee_requests
#: code:addons/employee_requests/models/hr_clearance_form.py:0
#, python-format
msgid "Sorry, Can not Clearance The employee %s Has delegation vehicle %s Is Valid"
msgstr "للأسف, لايمكن إخلا طرف للموظف %s لديه تفويض على المركبة %s ساري."

View File

@ -51,6 +51,38 @@ class HrClearanceForm(models.Model):
company_id = fields.Many2one('res.company',string="Company", default=lambda self: self.env.user.company_id)
def check_custody(self):
# Check if exp_custody_petty_cash module is installed
Module = self.env['ir.module.module'].sudo()
emp_custody = Module.search([('state', '=', 'installed'), ('name', '=', 'exp_employee_custody')])
petty_cash_modules = Module.search([('state', '=', 'installed'), ('name', '=', 'hr_expense_petty_cash')])
modules = Module.search([('state', '=', 'installed'), ('name', '=', 'exp_custody_petty_cash')])
fleet = Module.search([('state', '=', 'installed'), ('name', '=', 'odex_fleet')])
if emp_custody:
# Check if employee has Employee Custody not in state Return done
employee_custody = self.env['custom.employee.custody'].search([('employee_id', '=', self.employee_id.id),
('state', 'in', ['direct', 'admin', 'approve'])])
if len(employee_custody) > 0:
raise exceptions.Warning(_('Sorry, Can Not Clearance The Employee %s Has custody %s Not Return') % (
self.employee_id.name, len(employee_custody)))
if petty_cash_modules:
# Check if employee has Employee Petty Cash Payment not in state Return done
employee_petty_cash_payment = self.env['petty.cash'].search([('partner_id', '=', self.employee_id.user_id.partner_id.id),
('state', 'in', ['submitted', 'running'])])
if len(employee_petty_cash_payment) > 0:
raise exceptions.Warning(_('Sorry, Can Not Clearance The Employee %s Has Petty Cash %s Not Return') % (
self.employee_id.name, len(employee_petty_cash_payment)))
if fleet:
# Check if employee has Employee fleet not in state Return done
employee_fleet = self.env['vehicle.delegation'].search([('employee_id', '=', self.employee_id.id),
('state', 'in', ['approve', 'in_progress'])])
if len(employee_fleet) > 0:
raise exceptions.Warning(_('Sorry, Can not Clearance The employee %s Has delegation vehicle %s Is Valid') % (
self.employee_id.name, len(employee_fleet)))
@api.constrains('employee_id')
def chick_hiring_date(self):
for item in self:
@ -59,36 +91,10 @@ class HrClearanceForm(models.Model):
raise exceptions.Warning(_('You can not Request Clearance The Employee have Not First Hiring Date'))
def draft(self):
self.state = "draft"
def submit(self):
# Check if exp_custody_petty_cash module is installed
Module = self.env['ir.module.module'].sudo()
emp_modules = Module.search([('state', '=', 'installed'), ('name', '=', 'exp_employee_custody')])
petty_cash_modules = Module.search([('state', '=', 'installed'), ('name', '=', 'hr_expense_petty_cash')])
if emp_modules:
# Check if employee has Employee Custody not in state Return done
employee_custody = self.env['custom.employee.custody'].search(
[('employee_id', '=', self.employee_id.id), ('state', 'in', ['submit', 'direct', 'admin', 'approve'])])
if len(employee_custody) > 0:
raise exceptions.Warning(
_(
'You can not Employee Clearance %s employee custody not in state Return Done for %s please '
'reconcile it') % (
self.employee_id.name, len(employee_custody)))
if petty_cash_modules:
# Check if employee has Employee Petty Cash Payment not in state Return done
employee_petty_cash_payment = self.env['petty.cash'].search(
[('partner_id', '=', self.employee_id.user_id.partner_id.id),
('state', 'in', ['submit', 'direct', 'fm', 'ceo', 'accepted', 'validate'])])
if len(employee_petty_cash_payment) > 0:
raise exceptions.Warning(
_('You can not Employee Clearance %s employee petty cash payment not in state Return Done for %s '
'please reconcile it') % (
self.employee_id.name, len(employee_petty_cash_payment)))
self.check_custody()
'''for item in self:
mail_content = "Hello I'm", item.employee_id.name, " request to Clearance Of ", item.clearance_type,"Please approved thanks."
main_content = {
@ -101,41 +107,7 @@ class HrClearanceForm(models.Model):
self.state = "submit"
def direct_manager(self):
# Check if exp_custody_petty_cash module is installed
Module = self.env['ir.module.module'].sudo()
emp_modules = Module.search([('state', '=', 'installed'), ('name', '=', 'exp_employee_custody')])
petty_cash_modules = Module.search([('state', '=', 'installed'), ('name', '=', 'hr_expense_petty_cash')])
modules = Module.search([('state', '=', 'installed'), ('name', '=', 'exp_custody_petty_cash')])
fleet = Module.search([('state', '=', 'installed'), ('name', '=', 'odex_fleet')])
if emp_modules:
# Check if employee has Employee Custody not in state Return done
employee_custody = self.env['custom.employee.custody'].search(
[('employee_id', '=', self.employee_id.id), ('state', 'in', ['submit', 'direct', 'admin', 'approve'])])
if len(employee_custody) > 0:
raise exceptions.Warning(
_('You can not Employee Clearance "%s" employee custody not in state Return '
'Done for "%s" please reconcile it') % (len(employee_custody), self.employee_id.name))
if petty_cash_modules:
# Check if employee has Employee Petty Cash Payment not in state Return done
employee_petty_cash_payment = self.env['petty.cash'].search(
[('partner_id', '=', self.employee_id.user_id.partner_id.id),
('state', 'in', ['submit', 'direct', 'fm', 'ceo', 'accepted', 'validate'])])
if len(employee_petty_cash_payment) > 0:
raise exceptions.Warning(
_('You can not Employee Clearance "%s" employee petty cash payment not in state Return '
'Done for "%s" please reconcile it') % (
len(employee_petty_cash_payment), self.employee_id.name))
if fleet:
employee_fleet = self.env['vehicle.delegation'].search(
[('employee_id', '=', self.employee_id.id),
('state', 'in', ['approve', 'in_progress'])])
if len(employee_fleet) > 0:
raise exceptions.Warning(_('Sorry, Can not Clearance The employee %s Has delegation vehicle %s Is Valid') % (
self.employee_id.name, len(employee_fleet)))
self.check_custody()
for rec in self:
manager = rec.sudo().employee_id.parent_id
hr_manager = rec.sudo().employee_id.company_id.hr_manager_id
@ -163,6 +135,7 @@ class HrClearanceForm(models.Model):
def done(self):
self.check_custody()
if not self.bank_attachment_id:
raise exceptions.Warning(_('The Clearance to be completed after the Bank Clearance Attachment'))