summaryrefslogtreecommitdiff
path: root/addons/barcodes/static/src/js/barcode_form_view.js
diff options
context:
space:
mode:
Diffstat (limited to 'addons/barcodes/static/src/js/barcode_form_view.js')
-rw-r--r--addons/barcodes/static/src/js/barcode_form_view.js109
1 files changed, 60 insertions, 49 deletions
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),
},
},
};
@@ -74,6 +74,53 @@ FormController.include({
}
},
/**
+ * @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).
*
* @private
@@ -87,6 +134,12 @@ FormController.include({
},
/**
* @private
+ */
+ _barcodeSave: function () {
+ return this.saveRecord();
+ },
+ /**
+ * @private
* @param {Object} candidate: record in the x2m
* @param {Object} current record
* @param {string} barcode sent by the scanner (string generate from keypress series)
@@ -111,7 +164,6 @@ FormController.include({
core.bus.on('barcode_scanned', this, this._barcodeScanned);
core.bus.on('keypress', this, this._quantityListener);
},
-
/**
* @private
*/
@@ -260,47 +312,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
*/
_quantityListener: function (event) {