details:   https://code.tryton.org/tryton/commit/09517f848359
branch:    8.2
user:      Cédric Krier <[email protected]>
date:      Wed Oct 28 18:08:00 2026 +0100
description:
        Wait for the completion of the ending action of the wizard to resolve 
its promise

        Closes #15180
        (grafted from ce7b16c31097e82d7eb661fbd3b59d2477eb19c3)
diffstat:

 sao/src/wizard.js |  29 ++++++++++++++++++-----------
 1 files changed, 18 insertions(+), 11 deletions(-)

diffs (92 lines):

diff -r 5201744d90b5 -r 09517f848359 sao/src/wizard.js
--- a/sao/src/wizard.js Wed Oct 28 13:31:52 2026 +0100
+++ b/sao/src/wizard.js Wed Oct 28 18:08:00 2026 +0100
@@ -138,15 +138,15 @@
             return process.call(this);
         },
         destroy: function(action) {
-            // TODO
+            // TODO: screen destroy
+            return jQuery.when();
         },
         end: function() {
             return Sao.rpc({
                 'method': 'wizard.' + this.action + '.delete',
                 'params': [this.session_id, this.session.context]
             }, this.session).then(action => {
-                this.destroy(action);
-                this.__prm.resolve();
+                return this.destroy(action).then(() => this.__prm.resolve());
             })
             .fail(() => {
                 Sao.Logger.warn(
@@ -264,18 +264,20 @@
             return button;
         },
         destroy: function(action) {
-            Sao.Wizard.Form._super.destroy.call(this, action);
+            let prm = Sao.Wizard.Form._super.destroy.call(this, action);
+            let promesses = [prm];
             switch (action) {
                 case 'reload menu':
-                    Sao.Session.current_session.reload_context()
+                    promesses.push(Sao.Session.current_session.reload_context()
                         .then(function() {
                             Sao.menu();
-                        });
+                        }));
                     break;
                 case 'reload context':
-                    Sao.Session.current_session.reload_context();
+                    
promesses.push(Sao.Session.current_session.reload_context());
                     break;
             }
+            return jQuery.when.apply(jQuery, promesses);
         },
         end: function() {
             return Sao.Wizard.Form._super.end.call(this).always(
@@ -335,7 +337,8 @@
             this.show();
         },
         destroy: function(action) {
-            Sao.Wizard.Dialog._super.destroy.call(this, action);
+            let prm = Sao.Wizard.Dialog._super.destroy.call(this, action);
+            let destroy_prm = jQuery.Deferred();
             const destroy = () => {
                 this.dialog.remove();
                 var dialog = jQuery('.wizard-dialog').filter(':visible')[0];
@@ -353,8 +356,8 @@
                 } else {
                     screen = dialog.screen;
                 }
+                let prm = jQuery.when();
                 if (screen) {
-                    var prm = jQuery.when();
                     if (screen.current_record && !is_menu) {
                         var ids;
                         if (screen.model_name == this.model) {
@@ -367,11 +370,14 @@
                         prm = screen.reload(ids, true);
                     }
                     if (action) {
-                        prm.then(function() {
-                            screen.client_action(action);
+                        prm = prm.then(function() {
+                            return screen.client_action(action);
                         });
                     }
                 }
+                prm.then(
+                    () => destroy_prm.resolve(),
+                    () => destroy_prm.reject());
             };
             if ((this.dialog.data('bs.modal') || {}).isShown) {
                 this.dialog.on('hidden.bs.modal', destroy);
@@ -379,6 +385,7 @@
             } else {
                 destroy();
             }
+            return jQuery.when.apply(jQuery, [prm, destroy_prm]);
         },
         show: function() {
             var view = this.screen.current_view;

Reply via email to