summaryrefslogtreecommitdiff
path: root/addons/barcodes/static/src
diff options
context:
space:
mode:
authorAaron Bohy <aab@odoo.com>2017-08-24 08:40:10 +0200
committerAaron Bohy <aab@odoo.com>2017-08-25 15:54:56 +0200
commitdec1bdb44d2ee2bf1874f0a5051bdd7720cbb4d7 (patch)
tree6aa9e441f04db6b6a98181c3c25c936fb82a7747 /addons/barcodes/static/src
parent3d5b2836754ff4a63315990e4f455c51a1e11177 (diff)
[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).
Diffstat (limited to 'addons/barcodes/static/src')
-rw-r--r--addons/barcodes/static/src/js/barcode_form_view.js9
1 files changed, 7 insertions, 2 deletions
diff --git a/addons/barcodes/static/src/js/barcode_form_view.js b/addons/barcodes/static/src/js/barcode_form_view.js
index 7b82e68405c..08872f8084a 100644
--- a/addons/barcodes/static/src/js/barcode_form_view.js
+++ b/addons/barcodes/static/src/js/barcode_form_view.js
@@ -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});
+ }
});
});
},