Merge pull request #2214 from expsa/manar_dev_hr_26_1
UPDATE hr_holidays_public
This commit is contained in:
commit
bec24d7c0c
|
|
@ -170,8 +170,7 @@ class LeaveCancellation(models.Model):
|
|||
rec.employee_id.parent_id.name))
|
||||
else:
|
||||
rec.write({'state': 'confirm'})
|
||||
if rec.cancellation_type == 'cancel':
|
||||
rec.leave_request_id.refuse()
|
||||
|
||||
|
||||
def get_pure_holiday_days(self):
|
||||
for item in self:
|
||||
|
|
@ -213,57 +212,61 @@ class LeaveCancellation(models.Model):
|
|||
|
||||
def approve(self):
|
||||
for item in self:
|
||||
balance = self.env['hr.holidays'].search([('employee_id', '=', item.employee_id.id),
|
||||
('holiday_status_id', '=',
|
||||
item.leave_request_id.holiday_status_id.id),
|
||||
('type', '=', 'add'),
|
||||
('check_allocation_view', '=', 'balance')])
|
||||
if balance:
|
||||
cancelled_days = self.get_pure_holiday_days()
|
||||
var_remaining_leaves = balance.remaining_leaves + cancelled_days
|
||||
var_taken_leaves = balance.leaves_taken - cancelled_days
|
||||
if item.cancellation_type == 'cut':
|
||||
balance = self.env['hr.holidays'].search([('employee_id', '=', item.employee_id.id),
|
||||
('holiday_status_id', '=',
|
||||
item.leave_request_id.holiday_status_id.id),
|
||||
('type', '=', 'add'),
|
||||
('check_allocation_view', '=', 'balance')])
|
||||
if balance:
|
||||
cancelled_days = self.get_pure_holiday_days()
|
||||
var_remaining_leaves = balance.remaining_leaves + cancelled_days
|
||||
var_taken_leaves = balance.leaves_taken - cancelled_days
|
||||
|
||||
|
||||
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 \
|
||||
# cancelled_days
|
||||
item.leave_request_id.canceled_duration = cancelled_days
|
||||
balance.write({
|
||||
'remaining_leaves': var_remaining_leaves,
|
||||
'leaves_taken': var_taken_leaves,
|
||||
# 'number_of_days_temp': var_remaining_leaves,
|
||||
#'virtual_remaining_leaves': var_remaining_leaves,
|
||||
})
|
||||
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 \
|
||||
# cancelled_days
|
||||
item.leave_request_id.canceled_duration = cancelled_days
|
||||
balance.write({
|
||||
'remaining_leaves': var_remaining_leaves,
|
||||
'leaves_taken': var_taken_leaves,
|
||||
# 'number_of_days_temp': var_remaining_leaves,
|
||||
#'virtual_remaining_leaves': var_remaining_leaves,
|
||||
})
|
||||
|
||||
Module = self.env['ir.module.module'].sudo()
|
||||
modules_reconcile = Module.search([('state', '=', 'installed'), ('name', '=', 'exp_payroll_loans')])
|
||||
if modules_reconcile:
|
||||
Module = self.env['ir.module.module'].sudo()
|
||||
modules_reconcile = Module.search([('state', '=', 'installed'), ('name', '=', 'exp_payroll_loans')])
|
||||
if modules_reconcile:
|
||||
|
||||
reconcile_leave_id = self.env['reconcile.leaves'].search([
|
||||
('yearly_vacation', '=', item.leave_request_id.id),
|
||||
('state', '=', 'pay'),
|
||||
])
|
||||
if item.leave_request_id.reconcile_leave:
|
||||
if not reconcile_leave_id:
|
||||
raise exceptions.Warning(_('Kindly, process the reconciliation of leave'
|
||||
' before process cancel leave'))
|
||||
date_start = dt.strptime(str(item.from_date), "%Y-%m-%d %H:%M:%S")
|
||||
date_end = dt.strptime(str(item.leave_cancellation_date), "%Y-%m-%d %H:%M:%S")
|
||||
cancel_leave_duration = int((date_end - date_start).days)
|
||||
self.env['contract.advantage'].create({
|
||||
"employee_id": item.employee_id.id,
|
||||
"contract_advantage_id": self.employee_id.contract_id and
|
||||
self.employee_id.contract_id.id or False,
|
||||
"type": "exception",
|
||||
"date_from": item.from_date,
|
||||
"date_to": item.leave_cancellation_date,
|
||||
"amount": reconcile_leave_id.salary / (30 / cancel_leave_duration),
|
||||
"benefits_discounts": item.salary_rule_id and
|
||||
item.salary_rule_id.id or False,
|
||||
})
|
||||
item.leave_request_id.remove_delegated_access()
|
||||
reconcile_leave_id = self.env['reconcile.leaves'].search([
|
||||
('yearly_vacation', '=', item.leave_request_id.id),
|
||||
('state', '=', 'pay'),
|
||||
])
|
||||
if item.leave_request_id.reconcile_leave:
|
||||
if not reconcile_leave_id:
|
||||
raise exceptions.Warning(_('Kindly, process the reconciliation of leave'
|
||||
' before process cancel leave'))
|
||||
date_start = dt.strptime(str(item.from_date), "%Y-%m-%d %H:%M:%S")
|
||||
date_end = dt.strptime(str(item.leave_cancellation_date), "%Y-%m-%d %H:%M:%S")
|
||||
cancel_leave_duration = int((date_end - date_start).days)
|
||||
self.env['contract.advantage'].create({
|
||||
"employee_id": item.employee_id.id,
|
||||
"contract_advantage_id": self.employee_id.contract_id and
|
||||
self.employee_id.contract_id.id or False,
|
||||
"type": "exception",
|
||||
"date_from": item.from_date,
|
||||
"date_to": item.leave_cancellation_date,
|
||||
"amount": reconcile_leave_id.salary / (30 / cancel_leave_duration),
|
||||
"benefits_discounts": item.salary_rule_id and
|
||||
item.salary_rule_id.id or False,
|
||||
})
|
||||
item.leave_request_id.remove_delegated_access()
|
||||
|
||||
elif item.cancellation_type == 'cancel':
|
||||
item.leave_request_id.refuse()
|
||||
|
||||
item.state = 'approve'
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue