[FIX] barcodes: don't redraw form twice
When scanning a command barcode, the view shouldn't be redrawn after the operation corresponding to the command is executed, for two reasons: first, it is useless as the view has already been reloaded, and second, it may cause issues if it has been destroyed meanwhile. For example, when scanning barcode O-CMD.MAIN-MENU from a picking form view: a do_action is performed to go back to the main barcode client action (so the current form view is destroyed), but an handler tried to redrawn the destroyed form view, which produced a crash because the session was required by Date fields, and it couldn't be provided (there were no more parent listening to provide it).
This commit is contained in:
@@ -240,8 +240,13 @@ FormController.include({
|
||||
if (prefixed && !hasCommand) {
|
||||
self.do_warn(_t('Error : Barcode command is undefined'), barcode);
|
||||
}
|
||||
return $.when.apply($, defs).then(function () {
|
||||
self.update({}, {reload: false});
|
||||
return self.alive($.when.apply($, defs)).then(function () {
|
||||
if (!prefixed) {
|
||||
// redraw the view if we scanned a real barcode (required if
|
||||
// we manually apply the change in JS, e.g. incrementing the
|
||||
// quantity)
|
||||
self.update({}, {reload: false});
|
||||
}
|
||||
});
|
||||
});
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user