From dec1bdb44d2ee2bf1874f0a5051bdd7720cbb4d7 Mon Sep 17 00:00:00 2001 From: Aaron Bohy Date: Thu, 24 Aug 2017 08:40:10 +0200 Subject: [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). --- addons/barcodes/static/src/js/barcode_form_view.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'addons/barcodes/static/src') 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}); + } }); }); }, -- cgit v1.2.3