diff options
| author | Arthur Maniet <arthurmaniet@me.com> | 2015-09-04 17:17:14 +0200 |
|---|---|---|
| committer | Arthur Maniet <arthurmaniet@me.com> | 2015-09-11 12:04:13 +0200 |
| commit | 5b96b4349e0e471635c5d138498e6d416116b023 (patch) | |
| tree | 730719941eadc9d5f79f47ed20b404766f22c97d /addons/barcodes/static/src/js/form_view_barcode_handler.js | |
| parent | 20a2bcd2f7fd62f7df0d791e181009b81c18a1fe (diff) | |
[IMP] barcodes: form view barcode handler 'pre_onchange_hook' mechanism
Since the method must return a deferred, resolve it with true to proceed with onchange
and with false to prevent the onchange. Deferred failure is not an option.
Diffstat (limited to 'addons/barcodes/static/src/js/form_view_barcode_handler.js')
| -rw-r--r-- | addons/barcodes/static/src/js/form_view_barcode_handler.js | 12 |
1 files changed, 5 insertions, 7 deletions
diff --git a/addons/barcodes/static/src/js/form_view_barcode_handler.js b/addons/barcodes/static/src/js/form_view_barcode_handler.js index 0c9ae7f86c0..ef876404ddf 100644 --- a/addons/barcodes/static/src/js/form_view_barcode_handler.js +++ b/addons/barcodes/static/src/js/form_view_barcode_handler.js @@ -31,10 +31,10 @@ var FormViewBarcodeHandler = common.AbstractField.extend(BarcodeHandlerMixin, { } }, - // Let subclasses add custom behaviour before onchange - // Return false in order to proceed with the onchange, anything else to prevent it. + // Let subclasses add custom behaviour before onchange. Must return a deferred. + // Resolve the deferred with true proceed with the onchange, false to prevent it. pre_onchange_hook: function(barcode) { - return false; + return $.Deferred.resolve(true); }, on_barcode_scanned: function(barcode) { @@ -50,10 +50,8 @@ var FormViewBarcodeHandler = common.AbstractField.extend(BarcodeHandlerMixin, { this.do_warn(_t('Error : Document not editable'), _t('To modify this document, please first start edition.')); else { // Call hook method possibly implemented by subclass - $.when(this.pre_onchange_hook(barcode)).then(function(result) { - if (result !== false) { - return result; - } else { + this.pre_onchange_hook(barcode).then(function(proceed) { + if (proceed === true) { // Wait for hypothetical ongoing onchange to finish self.form_view.onchanges_mutex.exec(function() { // A real onchange is triggered when a value actually changes (which can correspond |
