details:   https://code.tryton.org/tryton/commit/cf04e7c23ecb
branch:    7.0
user:      Cédric Krier <[email protected]>
date:      Thu Apr 16 23:00:54 2026 +0200
description:
        Execute only one menu item and button actions at a time per tab

        Closes #14769
        (grafted from 4a6e16fdbcc2c35018a3b6ec76ccbbebf442c936)
diffstat:

 sao/src/tab.js |  21 ++++++++++++---------
 1 files changed, 12 insertions(+), 9 deletions(-)

diffs (49 lines):

diff -r bec9036d96d0 -r cf04e7c23ecb sao/src/tab.js
--- a/sao/src/tab.js    Thu Apr 16 22:50:42 2026 +0200
+++ b/sao/src/tab.js    Thu Apr 16 23:00:54 2026 +0200
@@ -13,6 +13,7 @@
             this.name = '';
             this.name_el = jQuery('<span/>');
             this.view_prm = jQuery.when();
+            this._action_running = false;
         },
         menu_def: function() {
             return [
@@ -153,8 +154,13 @@
                     this.menu_buttons[item.id] = menuitem;
                     link.click(evt => {
                         evt.preventDefault();
-                        if (!menuitem.hasClass('disabled')) {
-                            this[item.id]();
+                        if (!menuitem.hasClass('disabled')
+                            && !this._action_running) {
+                            this._action_running = true;
+                            (this[item.id]() || jQuery.when())
+                                .always(() => {
+                                    this._action_running = false;
+                                });
                         }
                     });
                 } else if (!item && previous) {
@@ -254,17 +260,14 @@
                 }
                 this.buttons[item.id].click(item, event => {
                     var item = event.data;
-                    var button = this.buttons[item.id];
-                    // Use data instead of disabled prop because the action may
-                    // actually disable the button.
-                    if (button.data('disabled')) {
+                    if (this._action_running) {
                         event.preventDefault();
                         return;
                     }
-                    button.data('disabled', true);
+                    this._action_running = true;
                     (this[item.id](this) || jQuery.when())
-                        .always(function() {
-                            button.data('disabled', false);
+                        .always(() => {
+                            this._action_running = false;
                         });
                 });
             };

Reply via email to