summaryrefslogtreecommitdiff
path: root/addons/barcodes/static/src/js
diff options
context:
space:
mode:
authorAaron Bohy <aab@odoo.com>2017-08-25 14:29:11 +0200
committerAaron Bohy <aab@odoo.com>2017-08-25 15:54:56 +0200
commit802dde31f3b58b8f26d6f6c584e5e4f8f392a482 (patch)
tree6aab2151a71e402ebde791559f30f020b3e8bcb4 /addons/barcodes/static/src/js
parent8019eacb4716befcc0affa4f8c9d554be2ec6655 (diff)
[FIX] web,barcodes: pager: FIRST and LAST actions
The barcode mechanism is supposed to handle commands PAGER-FIRST (go to first record referenced in the pager) and PAGER-LAST (go to last record). Before this rev., it wasn't the case. We needed to add an option 'notifyChange' to the updateState function of the pager, to ensure that the form is correctly reloaded when the pager cursor is manually set (by the barcode handler) on the first or last element.
Diffstat (limited to 'addons/barcodes/static/src/js')
-rw-r--r--addons/barcodes/static/src/js/barcode_form_view.js25
1 files changed, 25 insertions, 0 deletions
diff --git a/addons/barcodes/static/src/js/barcode_form_view.js b/addons/barcodes/static/src/js/barcode_form_view.js
index 8f6a3b0a3e2..5b042999bf6 100644
--- a/addons/barcodes/static/src/js/barcode_form_view.js
+++ b/addons/barcodes/static/src/js/barcode_form_view.js
@@ -31,6 +31,8 @@ FormController.include({
'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),
},
},
};
@@ -259,6 +261,29 @@ 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));
},