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
This commit is contained in:
+7
-8
@@ -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();
|
||||
}
|
||||
});
|
||||
|
||||
}());
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user