From 7398dcfed71ad0619ef1dadc8c80bd043496fcbc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Tue, 16 Jun 2026 13:41:49 +0200 Subject: [PATCH] Restore initial state when the execution of a wizard fails Since 1aad63cbbba7 there is a check that the button from a wizard are triggered from the same state as they were created. But when an exception is raised during the execution, the wizard must be put back to the initial state such that buttons can still be triggered again. Closes #14895 (grafted from 0eddec418366403871755be8ba3b750a9c0fcdf4) --HG-- branch : 8.0 --- sao/src/wizard.js | 15 +++++++-------- tryton/tryton/gui/window/wizard.py | 10 +++++----- 2 files changed, 12 insertions(+), 13 deletions(-) diff --git a/sao/src/wizard.js b/sao/src/wizard.js index 5a2971d45f..aa43fd55ce 100644 --- a/sao/src/wizard.js +++ b/sao/src/wizard.js @@ -43,20 +43,22 @@ 'params': [this.session.context] }, this.session).then(result => { this.session_id = result[0]; - this.start_state = this.state = result[1]; + this.start_state = result[1]; this.end_state = result[2]; - return this.process(); + return this.process(this.start_state); }, () => { this.destroy(); }); return this.__prm.promise(); }, - process: function() { + process: function(state) { if (this.__processing || this.__waiting_response) { return jQuery.when(); } this.__processing = true; var process = function() { + let current_state = this.state; + this.state = state; if (this.state == this.end_state) { return this.end(); } @@ -121,6 +123,7 @@ this.state = this.end_state; this.end(); } + this.state = current_state; this.__processing = false; }); }; @@ -158,8 +161,7 @@ return; } this.info_bar.clear(); - this.state = definition.state; - this.process(); + this.process(definition.state); }, _get_button: function(definition) { var style = 'btn-default'; @@ -401,9 +403,6 @@ hide: function() { this.dialog.modal('hide'); }, - state_changed: function() { - this.process(); - } }); }()); diff --git a/tryton/tryton/gui/window/wizard.py b/tryton/tryton/gui/window/wizard.py index dce983d666..747a82e2c7 100644 --- a/tryton/tryton/gui/window/wizard.py +++ b/tryton/tryton/gui/window/wizard.py @@ -71,11 +71,10 @@ class Wizard(InfoBar): self.destroy() return self.session_id, self.start_state, self.end_state = result - self.state = self.start_state - self.process() + self.process(self.start_state) RPCExecute('wizard', action, 'create', callback=callback) - def process(self): + def process(self, state): from tryton.action import Action if self.__processing or self.__waiting_response: return @@ -88,6 +87,7 @@ class Wizard(InfoBar): } else: data = {} + current_state, self.state = self.state, state def callback(result): try: @@ -98,6 +98,7 @@ class Wizard(InfoBar): or not self.screen): self.state = self.end_state self.end() + self.state = current_state self.__processing = False return @@ -179,8 +180,7 @@ class Wizard(InfoBar): self.screen.invalid_message(), Gtk.MessageType.ERROR) return self.info_bar_clear() - self.state = state - self.process() + self.process(state) def _get_button(self, definition): button = Button(definition)