Merge pull request #1905 from expsa/bakry_hr

fix
This commit is contained in:
bakry 2024-12-10 18:12:17 +03:00 committed by GitHub
commit fa9bab0b54
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 9 additions and 7 deletions

View File

@ -59,29 +59,29 @@ class HrClearanceForm(models.Model):
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')])
employee_name = self.sudo().employee_id
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),
employee_custody = self.env['custom.employee.custody'].search([('employee_id', '=', employee_name.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)))
employee_name.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),
employee_petty_cash_payment = self.env['petty.cash'].search([('partner_id', '=', employee_name.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)))
employee_name.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),
employee_fleet = self.env['vehicle.delegation'].search([('employee_id', '=', employee_name.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)))
employee_name.name, len(employee_fleet)))
@api.constrains('employee_id')
def chick_hiring_date(self):
@ -120,9 +120,11 @@ class HrClearanceForm(models.Model):
rec.write({'state': 'direct_manager'})
def info_system(self):
self.check_custody()
self.state = "info_system"
def admin_manager(self):
self.check_custody()
self.state = "admin_manager"
def wait(self):