summaryrefslogtreecommitdiff
path: root/addons/pos_cache/static/src
diff options
context:
space:
mode:
authorGéry Debongnie <ged@odoo.com>2017-03-05 09:34:56 +0100
committerAaron Bohy <aab@odoo.com>2017-04-11 19:44:38 +0200
commite5740270568404d71a3bc093074a085c9c2eded8 (patch)
tree7b84740d92c550236de25a37cf37d244760bdbf3 /addons/pos_cache/static/src
parent0df9968433389e0d504276cd711473c2eef937ae (diff)
[REF] web,*: remove 'web.model' and 'web.dataModel
Use this.rpc instead of Model object, with web.ajax if necessary. nb: EventDispatcherMixin include now the custom_events managment instead of widget
Diffstat (limited to 'addons/pos_cache/static/src')
-rw-r--r--addons/pos_cache/static/src/js/pos_cache.js71
1 files changed, 37 insertions, 34 deletions
diff --git a/addons/pos_cache/static/src/js/pos_cache.js b/addons/pos_cache/static/src/js/pos_cache.js
index 29d5e3bfbc4..1e49b36e4c9 100644
--- a/addons/pos_cache/static/src/js/pos_cache.js
+++ b/addons/pos_cache/static/src/js/pos_cache.js
@@ -1,43 +1,46 @@
odoo.define('pos_cache.pos_cache', function (require) {
- "use strict";
- var core = require('web.core');
- var models = require('point_of_sale.models');
- var Model = require('web.DataModel');
- var _t = core._t;
+"use strict";
- var posmodel_super = models.PosModel.prototype;
- models.PosModel = models.PosModel.extend({
- load_server_data: function () {
- var self = this;
+var models = require('point_of_sale.models');
+var ajax = require('web.ajax');
+var core = require('web.core');
+var rpc = require('web.rpc');
+var _t = core._t;
- var product_index = _.findIndex(this.models, function (model) {
- return model.model === "product.product";
- });
+var posmodel_super = models.PosModel.prototype;
+models.PosModel = models.PosModel.extend({
+ load_server_data: function () {
+ var self = this;
- // 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_index = _.findIndex(this.models, function (model) {
+ return model.model === "product.product";
+ });
- // 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);
- }
+ // 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;
- return posmodel_super.load_server_data.apply(this, arguments).then(function () {
- var records = new Model('pos.config').call('get_products_from_cache',
- [self.pos_session.config_id[0], product_fields, product_domain]);
+ // 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);
+ }
- self.chrome.loading_message(_t('Loading') + ' product.product', 1);
- return records.then(function (product) {
- self.db.add_products(product);
- });
+ return posmodel_super.load_server_data.apply(this, arguments).then(function () {
+ var records = rpc.query({model: 'pos.config', method: 'get_products_from_cache'})
+ .args([self.pos_session.config_id[0], product_fields, product_domain])
+ .exec({callback: ajax.rpc.bind(ajax)});
+ self.chrome.loading_message(_t('Loading') + ' product.product', 1);
+ return records.then(function (product) {
+ self.db.add_products(product);
});
- },
- });
+ });
+ },
+});
+
});