Hii,
I have added one extra level of approval that is substitute employee when any employee creates leave request in Leaves App in statusbar.
state = fields.Selection([ ('draft', 'To Submit'),
('cancel', 'Cancelled'),
('confirm', 'To Approve'),
('refuse', 'Refused'),
('validate_substitute', 'Substitute Approval'), # Additional level of approval, customization
('validate1', 'Second Approval'),
('validate', 'Approved')])
After substitute employee approval, when clicking on Approve button getting following error..
Leave request must be confirmed ("To Approve") in order to approve it.
This error message is coming from following method in hr_leave.py class....
@api.multi def action_approve(self):
# if validation_type == 'both': this method is the first approval approval
# if validation_type != 'both': this method calls action_validate() below
if any(holiday.state != 'confirm' for holiday in self):
raise UserError(_('Leave request must be confirmed ("To Approve") in order to approve it.'))
current_employee = self.env['hr.employee'].search([('user_id', '=', self.env.uid)], limit=1)
self.filtered(lambda hol: hol.validation_type == 'both').write({'state': 'validate1', 'first_approver_id': current_employee.id})
self.filtered(lambda hol: not hol.validation_type == 'both').action_validate()
if not self.env.context.get('leave_fast_create'):
self.activity_update()
return True
In this method I want to change 'confirm' to 'validate_substitute' like following
if any(holiday.state != 'validate_substitute' for holiday in self):
How I can achieve it in method overriding?
Or should I write it complete in my inherited class?
Thanks,