From cbe6e0c79396238e38fb27fe87f7a4e12d56d752 Mon Sep 17 00:00:00 2001 From: Simone Orsi Date: Wed, 8 Dec 2021 14:30:19 +0100 Subject: [PATCH] sf_mobile_base: fix demo mode OdooMocked --- .../static/wms/src/services/odoo.js | 27 ++++++++++++------- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/shopfloor_mobile_base/static/wms/src/services/odoo.js b/shopfloor_mobile_base/static/wms/src/services/odoo.js index e90f85436f..c6cd4a9212 100644 --- a/shopfloor_mobile_base/static/wms/src/services/odoo.js +++ b/shopfloor_mobile_base/static/wms/src/services/odoo.js @@ -14,26 +14,34 @@ export class OdooMixin { this.debug = this.params.debug; } call(path, data, method = "POST", fullpath = false) { - const endpoint = fullpath ? path : this.usage + "/" + path; - return this._call(endpoint, method, data); + const endpoint_info = this._make_endpoint_info(path, fullpath); + return this._call(endpoint_info, method, data); } post(path, data, fullpath = false) { if (_.isArray(path)) { path = path.join("/"); } - const endpoint = fullpath ? path : this.usage + "/" + path; - return this._call(endpoint, "POST", data); + const endpoint_info = this._make_endpoint_info(path, fullpath); + return this._call(endpoint_info, "POST", data); } get(path, data, fullpath = false) { if (_.isArray(path)) { path = path.join("/"); } - const endpoint = fullpath ? path : this.usage + "/" + path; - return this._call(endpoint, "GET", data); + const endpoint_info = this._make_endpoint_info(path, fullpath); + return this._call(endpoint_info, "GET", data); } - _call(endpoint, method, data) { + _make_endpoint_info(path, fullpath) { + return { + endpoint: fullpath ? path : this.usage + "/" + path, + path: path, + fullpath: fullpath, + }; + } + _call(endpoint_info, method, data) { + let endpoint = endpoint_info.endpoint; if (this.debug) { - console.log("CALL", endpoint); + console.log("DEBUG CALL", endpoint); } const self = this; const params = { @@ -115,7 +123,8 @@ export class OdooMocked extends OdooMixin { _set_demo_data() { this.demo_data = demotools.get_case(this.usage); } - call(path, data, method = "POST", fullpath = false) { + _call(endpoint_info, method, data) { + let path = endpoint_info.path; this._set_demo_data(); console.log("CALL:", path, this.usage); console.dir("CALL data:", data);