summaryrefslogtreecommitdiff
path: root/addons/pos_cache/static/src/js/pos_cache.js
diff options
context:
space:
mode:
authorPierre Masereel <pim@odoo.com>2019-06-28 14:01:59 +0000
committerPierre Masereel <pim@odoo.com>2019-06-28 14:05:58 +0000
commitb9889e081e3ac0da12709e639bd2382dbca6a2e8 (patch)
treede81aff745977fcd97c98bce4bb8d7f78dc7215d /addons/pos_cache/static/src/js/pos_cache.js
parentf40ca3bbb7ad2ee9bcbe94c07535aa0c3561c528 (diff)
[FIX] pos_cache: eval domain before sending it to server
Since changes made on 'product.product' model in rev: 30e4d89a62c21e76db651ca54f8c132b96e7668d the domain is not represented as a string, but as a function, and that leads to error as the javascript function is sent to the server instead of a string representing a domain. So we check the type of domain to see if we have to evaluate a function or send the domain as a string closes odoo/odoo#34453 Signed-off-by: pimodoo <pimodoo@users.noreply.github.com>
Diffstat (limited to 'addons/pos_cache/static/src/js/pos_cache.js')
-rw-r--r--addons/pos_cache/static/src/js/pos_cache.js17
1 files changed, 8 insertions, 9 deletions
diff --git a/addons/pos_cache/static/src/js/pos_cache.js b/addons/pos_cache/static/src/js/pos_cache.js
index 6a26143cc6e..1b59761bc26 100644
--- a/addons/pos_cache/static/src/js/pos_cache.js
+++ b/addons/pos_cache/static/src/js/pos_cache.js
@@ -15,22 +15,21 @@ models.PosModel = models.PosModel.extend({
return model.model === "product.product";
});
- // Give both the fields and domain to pos_cache in the
- // backend. This way we don't have to hardcode these
- // values in the backend and they automatically stay in
- // sync with whatever is defined (and maybe extended by
- // other modules) in js.
- var product_model = this.models[product_index];
- var product_fields = product_model.fields;
- var product_domain = product_model.domain;
+ var product_model = self.models[product_index];
// We don't want to load product.product the normal
// uncached way, so get rid of it.
if (product_index !== -1) {
this.models.splice(product_index, 1);
}
-
return posmodel_super.load_server_data.apply(this, arguments).then(function () {
+ // Give both the fields and domain to pos_cache in the
+ // backend. This way we don't have to hardcode these
+ // values in the backend and they automatically stay in
+ // sync with whatever is defined (and maybe extended by
+ // other modules) in js.
+ var product_fields = typeof product_model.fields === 'function' ? product_model.fields(self) : product_model.fields;
+ var product_domain = typeof product_model.domain === 'function' ? product_model.domain(self) : product_model.domain;
var records = rpc.query({
model: 'pos.config',
method: 'get_products_from_cache',