details:   https://code.tryton.org/tryton/commit/1ef76096dc94
branch:    default
user:      Cédric Krier <[email protected]>
date:      Thu Aug 20 11:56:35 2026 +0200
description:
        Disable the wizard buttons while processing

        Closes #15026
diffstat:

 sao/src/wizard.js                  |  21 +++++++++++++++------
 tryton/tryton/gui/window/wizard.py |  14 +++++++++++---
 2 files changed, 26 insertions(+), 9 deletions(-)

diffs (135 lines):

diff -r 0697a96aaf6c -r 1ef76096dc94 sao/src/wizard.js
--- a/sao/src/wizard.js Tue Aug 11 12:10:58 2026 +0200
+++ b/sao/src/wizard.js Thu Aug 20 11:56:35 2026 +0200
@@ -56,6 +56,7 @@
                 return jQuery.when();
             }
             this.__processing = true;
+            this.update_buttons();
             var process = function() {
                 let current_state = this.state;
                 this.state = state;
@@ -117,7 +118,10 @@
                         prms.push(execute_actions());
                     }
                     return jQuery.when.apply(jQuery, prms).then(
-                        () => this.__processing = false);
+                        () => {
+                            this.__processing = false;
+                            this.update_buttons();
+                        });
                 }, result => {
                     if (!result || !this.screen) {
                         this.state = this.end_state;
@@ -125,6 +129,7 @@
                     }
                     this.state = current_state;
                     this.__processing = false;
+                    this.update_buttons();
                 });
             };
             return process.call(this);
@@ -172,6 +177,7 @@
             }
             var button = new Sao.common.Button(
                 definition, undefined, undefined, style);
+            button.set_state(this.screen ? this.screen.current_record : null);
             this.states[definition.state] = button;
             return button;
         },
@@ -180,16 +186,16 @@
             this.info_bar.refresh();
         },
         update_buttons: function() {
-            var record = this.screen.current_record;
+            let record = this.screen ? this.screen.current_record : null;
             for (var state in this.states) {
-                var button = this.states[state];
+                let button = this.states[state];
                 button.set_state(record);
+                if (this.__processing) {
+                    button.el.prop('disabled', true);
+                }
             }
         },
         update: function(view, buttons) {
-            for (const button of buttons) {
-                this._get_button(button);
-            }
             if (this.screen) {
                 this.screen.windows.splice(
                     this.screen.windows.indexOf(this), 1);
@@ -204,6 +210,9 @@
                 'title': this.name,
             }).text(Sao.common.ellipsize(this.name, 80)));
             this.widget.append(this.screen.screen_container.el);
+            for (let button of buttons) {
+                this._get_button(button);
+            }
         }
     });
 
diff -r 0697a96aaf6c -r 1ef76096dc94 tryton/tryton/gui/window/wizard.py
--- a/tryton/tryton/gui/window/wizard.py        Tue Aug 11 12:10:58 2026 +0200
+++ b/tryton/tryton/gui/window/wizard.py        Thu Aug 20 11:56:35 2026 +0200
@@ -79,6 +79,7 @@
         if self.__processing or self.__waiting_response:
             return
         self.__processing = True
+        self.update_buttons()
 
         ctx = self.context.copy()
         if self.screen:
@@ -100,6 +101,7 @@
                     self.end()
                 self.state = current_state
                 self.__processing = False
+                self.update_buttons()
                 return
 
             if 'view' in result:
@@ -141,6 +143,7 @@
             else:
                 execute_actions()
             self.__processing = False
+            self.update_buttons()
 
         RPCExecute('wizard', self.action, 'execute', self.session_id, data,
             self.state, context=ctx, callback=callback)
@@ -188,6 +191,8 @@
         response = len(self.states)
         self.response2button[response] = button
         button.show()
+        button.state_set(
+            self.screen.current_record if self.screen else None)
         return button
 
     def record_modified(self):
@@ -195,14 +200,14 @@
         self.info_bar_refresh()
 
     def update_buttons(self):
-        record = self.screen.current_record
+        record = self.screen.current_record if self.screen else None
         for button in self.states.values():
             button.state_set(record)
+            if self.__processing:
+                button.set_sensitive(False)
 
     def update(self, view, buttons):
         tooltips = common.Tooltips()
-        for button in buttons:
-            self._get_button(button)
 
         if self.screen:
             self.screen.windows.remove(self)
@@ -250,6 +255,9 @@
         self.widget.pack_start(
             self.create_info_bar(), expand=False, fill=True, padding=0)
 
+        for button in buttons:
+            self._get_button(button)
+
 
 class WizardForm(Wizard, TabContent):
     "Wizard"

Reply via email to