diff --git a/addons/barcodes/static/src/js/barcode_form_view.js b/addons/barcodes/static/src/js/barcode_form_view.js index 5b042999bf6..3f1c5ef1a86 100644 --- a/addons/barcodes/static/src/js/barcode_form_view.js +++ b/addons/barcodes/static/src/js/barcode_form_view.js @@ -26,13 +26,13 @@ FormController.include({ this.activeBarcode = { form_view: { commands: { - 'O-CMD.EDIT': this._onEdit.bind(this), - 'O-CMD.CANCEL': this._onDiscard.bind(this), - 'O-CMD.SAVE': this._onCommandSave.bind(this), - 'O-CMD.PAGER-PREV': this._onCommandPrevious.bind(this), - 'O-CMD.PAGER-NEXT': this._onCommandNext.bind(this), - 'O-CMD.PAGER-FIRST': this._onCommandFirst.bind(this), - 'O-CMD.PAGER-LAST': this._onCommandLast.bind(this), + 'O-CMD.EDIT': this._barcodeEdit.bind(this), + 'O-CMD.CANCEL': this._barcodeDiscard.bind(this), + 'O-CMD.SAVE': this._barcodeSave.bind(this), + 'O-CMD.PAGER-PREV': this._barcodePagerPrevious.bind(this), + 'O-CMD.PAGER-NEXT': this._barcodePagerNext.bind(this), + 'O-CMD.PAGER-FIRST': this._barcodePagerFirst.bind(this), + 'O-CMD.PAGER-LAST': this._barcodePagerLast.bind(this), }, }, }; @@ -73,6 +73,53 @@ FormController.include({ return this._barcodeWithoutCandidate(record, barcode, activeBarcode); } }, + /** + * @private + */ + _barcodeDiscard: function () { + return this.discardChanges(); + }, + /** + * @private + */ + _barcodeEdit: function () { + return this._setMode('edit'); + }, + /** + * @private + */ + _barcodePagerFirst: function () { + var self = this; + return this.mutex.exec(function () {}).then(function () { + self.pager.updateState({ + current_min: 1, + }, {notifyChange: true}); + }); + }, + /** + * @private + */ + _barcodePagerLast: function () { + var self = this; + return this.mutex.exec(function () {}).then(function () { + var state = self.model.get(self.handle, {raw: true}); + self.pager.updateState({ + current_min: state.count, + }, {notifyChange: true}); + }); + }, + /** + * @private + */ + _barcodePagerNext: function () { + return this.mutex.exec(function () {}).then(this.pager.next.bind(this.pager)); + }, + /** + * @private + */ + _barcodePagerPrevious: function () { + return this.mutex.exec(function () {}).then(this.pager.previous.bind(this.pager)); + }, /** * Returns true iff the given barcode matches the given record (candidate). * @@ -85,6 +132,12 @@ FormController.include({ _barcodeRecordFilter: function (candidate, barcode, activeBarcode) { return candidate.data.product_barcode === barcode; }, + /** + * @private + */ + _barcodeSave: function () { + return this.saveRecord(); + }, /** * @private * @param {Object} candidate: record in the x2m @@ -111,7 +164,6 @@ FormController.include({ core.bus.on('barcode_scanned', this, this._barcodeScanned); core.bus.on('keypress', this, this._quantityListener); }, - /** * @private */ @@ -258,47 +310,6 @@ FormController.include({ }); }); }, - /** - * @private - */ - _onCommandFirst: function () { - var self = this; - return this.mutex.exec(function () {}).then(function () { - self.pager.updateState({ - current_min: 1, - }, {notifyChange: true}); - }); - }, - /** - * @private - */ - _onCommandLast: function () { - var self = this; - return this.mutex.exec(function () {}).then(function () { - var state = self.model.get(self.handle, {raw: true}); - self.pager.updateState({ - current_min: state.count, - }, {notifyChange: true}); - }); - }, - /** - * @private - */ - _onCommandNext: function () { - return this.mutex.exec(function () {}).then(this.pager.next.bind(this.pager)); - }, - /** - * @private - */ - _onCommandPrevious: function () { - return this.mutex.exec(function () {}).then(this.pager.previous.bind(this.pager)); - }, - /** - * @private - */ - _onCommandSave: function () { - return this.saveRecord(); - }, /** * @private * @param {KeyEvent} event