summaryrefslogtreecommitdiff
path: root/addons/barcodes/static/src/js
diff options
context:
space:
mode:
authorMOENS Alexandre <mao@odoo.com>2018-06-05 14:09:32 +0200
committerSimon Lejeune <sle@openerp.com>2018-06-11 16:18:18 +0200
commitd13fb14f1ecec10f1308afccee3f69e1daa67e9f (patch)
treebfb3850f1a66c91fccc0d5c773f2ff3d9a1abaa5 /addons/barcodes/static/src/js
parentdefff5f191558e2f1dd371a885f80acd3c92f0be (diff)
[REF] barcodes: pager: warn if a pager isn't present
If a barcode triggering an action on the pager was scanned while a pager wasn't present in the page (see the workorder tablet view), a traceback happened. We display a warning instead. Task: 1831245
Diffstat (limited to 'addons/barcodes/static/src/js')
-rw-r--r--addons/barcodes/static/src/js/barcode_form_view.js26
1 files changed, 24 insertions, 2 deletions
diff --git a/addons/barcodes/static/src/js/barcode_form_view.js b/addons/barcodes/static/src/js/barcode_form_view.js
index 363f33606c3..525d0b84ebd 100644
--- a/addons/barcodes/static/src/js/barcode_form_view.js
+++ b/addons/barcodes/static/src/js/barcode_form_view.js
@@ -91,6 +91,10 @@ FormController.include({
_barcodePagerFirst: function () {
var self = this;
return this.mutex.exec(function () {}).then(function () {
+ if (!self.pager) {
+ self.do_warn(_t('Error: Pager not available'));
+ return;
+ }
self.pager.updateState({
current_min: 1,
}, {notifyChange: true});
@@ -102,6 +106,10 @@ FormController.include({
_barcodePagerLast: function () {
var self = this;
return this.mutex.exec(function () {}).then(function () {
+ if (!self.pager) {
+ self.do_warn(_t('Error: Pager not available'));
+ return;
+ }
var state = self.model.get(self.handle, {raw: true});
self.pager.updateState({
current_min: state.count,
@@ -112,13 +120,27 @@ FormController.include({
* @private
*/
_barcodePagerNext: function () {
- return this.mutex.exec(function () {}).then(this.pager.next.bind(this.pager));
+ var self = this;
+ return this.mutex.exec(function () {}).then(function () {
+ if (!self.pager) {
+ self.do_warn(_t('Error: Pager not available'));
+ return;
+ }
+ self.pager.next();
+ });
},
/**
* @private
*/
_barcodePagerPrevious: function () {
- return this.mutex.exec(function () {}).then(this.pager.previous.bind(this.pager));
+ var self = this;
+ return this.mutex.exec(function () {}).then(function () {
+ if (!self.pager) {
+ self.do_warn(_t('Error: Pager not available'));
+ return;
+ }
+ self.pager.previous();
+ });
},
/**
* Returns true iff the given barcode matches the given record (candidate).