From 1e7d6257705423f1a33a3ca0d6cd3b858c19d1b0 Mon Sep 17 00:00:00 2001 From: Pierre Masereel Date: Wed, 14 Sep 2022 15:00:21 +0000 Subject: [PATCH] [FIX] point_of_sale: fix use iot proxy address When you are in odoo community, you have to set an ip adress to configure iot box and check boxes to add devices to your POS. When you use the devices in POS this way, you get a traceback because of trying use 'this' which is not the correct scope of the function. To avoid such issue, we are using arrow functions that keep the 'this' of wherer they are called. closes odoo/odoo#100226 X-original-commit: aaa0f836dfce9efa27e9b2603edddd68781c2048 Signed-off-by: Masereel Pierre --- addons/point_of_sale/static/src/js/Chrome.js | 6 +++--- addons/point_of_sale/static/src/js/devices.js | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/addons/point_of_sale/static/src/js/Chrome.js b/addons/point_of_sale/static/src/js/Chrome.js index d0d7039d4f3..36a67711cf9 100644 --- a/addons/point_of_sale/static/src/js/Chrome.js +++ b/addons/point_of_sale/static/src/js/Chrome.js @@ -206,20 +206,20 @@ odoo.define('point_of_sale.Chrome', function(require) { } connect_to_proxy() { - return new Promise(function (resolve, reject) { + return new Promise((resolve, reject) => { this.env.barcode_reader.disconnect_from_proxy(); this.state.loadingSkipButtonIsShown = true; this.env.proxy.autoconnect({ force_ip: this.env.pos.config.proxy_ip || undefined, progress: function(prog){}, }).then( - function () { + () => { if (this.env.pos.config.iface_scan_via_proxy) { this.env.barcode_reader.connect_to_proxy(); } resolve(); }, - function (statusText, url) { + (statusText, url) => { // this should reject so that it can be captured when we wait for pos.ready // in the chrome component. // then, if it got really rejected, we can show the error. diff --git a/addons/point_of_sale/static/src/js/devices.js b/addons/point_of_sale/static/src/js/devices.js index 1613d297474..a285af5d2b4 100644 --- a/addons/point_of_sale/static/src/js/devices.js +++ b/addons/point_of_sale/static/src/js/devices.js @@ -447,7 +447,7 @@ var ProxyDevice = core.Class.extend(mixins.PropertiesMixin,{ }, update_customer_facing_display: function(html) { - if (this.posbox_supports_display) { + if (this.posbox_supports_display && this.get('status').status == 'connected') { return this.message('customer_facing_display', { html: html }, { timeout: 5000 });