Skip to content

Commit

Permalink
sf_mobile_base: fix demo mode OdooMocked
Browse files Browse the repository at this point in the history
  • Loading branch information
simahawk committed Jan 28, 2022
1 parent a7c629e commit 18ec7d5
Showing 1 changed file with 18 additions and 9 deletions.
27 changes: 18 additions & 9 deletions shopfloor_mobile_base/static/wms/src/services/odoo.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 18ec7d5

Please sign in to comment.