From ecda01d83ea17f882cfdea2ed694dc0e907991ad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=B9=8F=E5=AE=87?= <9664676+pengyuthon@user.noreply.gitee.com> Date: Wed, 14 Jan 2026 14:45:15 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- yuthon_holiday/models/inherit_hr_leave.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/yuthon_holiday/models/inherit_hr_leave.py b/yuthon_holiday/models/inherit_hr_leave.py index 036fa5068..8dfc006c9 100644 --- a/yuthon_holiday/models/inherit_hr_leave.py +++ b/yuthon_holiday/models/inherit_hr_leave.py @@ -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",