@@ -88,6 +88,14 @@ class HrLeave(models.Model):
|
||||
for holiday in self.filtered(lambda holiday: holiday.state not in ['draft', 'cancel', 'confirm']):
|
||||
raise UserError(error_message % (state_description_values.get(holiday.state),))
|
||||
|
||||
@api.model
|
||||
def write(self, vals):
|
||||
if not self.env.context.get('leave_skip_state_check'):
|
||||
self = self.with_context(leave_skip_state_check=True)
|
||||
if 'state' not in vals and self.filtered(lambda r: r.state != 'draft'):
|
||||
vals['state'] = 'draft'
|
||||
return super(HrLeave, self).write(vals)
|
||||
|
||||
def action_leave_wizard(self):
|
||||
return {
|
||||
"type": "ir.actions.act_window",
|
||||
|
||||
Reference in New Issue
Block a user