diff options
| author | Christophe Matthieu <chm@odoo.com> | 2017-04-24 16:18:48 +0200 |
|---|---|---|
| committer | Christophe Matthieu <chm@odoo.com> | 2017-04-24 17:05:20 +0200 |
| commit | 6d4e223c18c44f8429b324ccb41845d148a6e76d (patch) | |
| tree | 52f3ee5604f1019c6dc6415f62cb128a96abdd4b /addons/barcodes/static/src/js | |
| parent | 72ed9702f13b4aefb692a16f3055571b44ca3287 (diff) | |
[FIX] barcode: various javascript fixes
* Avoid unnecessary reload
* send option to saveRecord
* Display error warning to set the quantity as option
Diffstat (limited to 'addons/barcodes/static/src/js')
| -rw-r--r-- | addons/barcodes/static/src/js/barcode_form_view.js | 28 |
1 files changed, 17 insertions, 11 deletions
diff --git a/addons/barcodes/static/src/js/barcode_form_view.js b/addons/barcodes/static/src/js/barcode_form_view.js index 2e22587fbe6..05b937c4f65 100644 --- a/addons/barcodes/static/src/js/barcode_form_view.js +++ b/addons/barcodes/static/src/js/barcode_form_view.js @@ -23,7 +23,7 @@ FormController.include({ 'O-CMD.NEW': 'createRecord', 'O-CMD.EDIT': 'toEditMode', 'O-CMD.CANCEL': 'discardChange', - 'O-CMD.SAVE': 'saveRecord', + 'O-CMD.SAVE': function () { return this.saveRecord({reload: true}); }, // 'O-CMD.PAGER-PREV': // 'O-CMD.PAGER-NEXT': } @@ -109,9 +109,7 @@ FormController.include({ _barcodeWithoutCandidate: function (record, barcode, activeBarcode) { var changes = {}; changes[activeBarcode.name] = barcode; - return this.model.notifyChanges(record.id, changes).then(function () { - return new $.Deferred().reject(); - }); + return this.model.notifyChanges(record.id, changes); }, /** * @private @@ -171,12 +169,15 @@ FormController.include({ } else { methodDef = method.call(this, barcode, activeBarcode); } - methodDef.always(function () { - var record = self.model.get(self.handle); - var candidate = self._getBarCodeRecord(record, barcode, activeBarcode); - activeBarcode.candidate = candidate; - def.resolve(); - }); + methodDef + .done(function () { + var record = self.model.get(self.handle); + var candidate = self._getBarCodeRecord(record, barcode, activeBarcode); + activeBarcode.candidate = candidate; + }) + .always(function () { + def.resolve(); + }); return def; }, /** @@ -231,7 +232,12 @@ FormController.include({ return; } - if (!_.compact(_.pluck(this.activeBarcode, 'candidate')).length) { + var barcodeInfos = _.filter(this.activeBarcode, 'setQuantityWithKeypress'); + if (!barcodeInfos.length) { + return; + } + + if (!_.compact(_.pluck(barcodeInfos, 'candidate')).length) { return this.do_warn(_t('Error : No last scanned barcode'), _t('To set the quantity please scan a barcode first.')); } |
