Browse Source

Merge PR #345 into 10.0

Signed-off-by legalsylvain
pull/424/head
OCA-git-bot 5 years ago
parent
commit
06c760ba09
  1. 31
      pos_product_template/static/src/js/ppt.js

31
pos_product_template/static/src/js/ppt.js

@ -396,6 +396,15 @@ odoo.define("pos_product_template.pos_product_template", function(require){
this._super(options); this._super(options);
}, },
add_products: function(products){
this._super(products);
// if pos_cache is also installed - then products are not available when product.templates are already loaded
// so we have to re add them here
if (this.raw_templates) {
this.add_templates(this.raw_templates);
}
},
get_product_by_value_and_products: function(value_id, products){ get_product_by_value_and_products: function(value_id, products){
var list = []; var list = [];
for (var i = 0, len = products.length; i < len; i++) { for (var i = 0, len = products.length; i < len; i++) {
@ -482,20 +491,9 @@ odoo.define("pos_product_template.pos_product_template", function(require){
- Load 'name' field of model product.product; - Load 'name' field of model product.product;
- Load product.template model; - Load product.template model;
*********************************************************** */ *********************************************************** */
// change product.product call
models.PosModel.prototype.models.some(function (model) {
if (model.model !== 'product.product') {
return false;
}
// add name and attribute_value_ids to list of fields
// to fetch for product.product
['name', 'attribute_value_ids'].forEach(function (field) {
if (model.fields.indexOf(field) == -1) {
model.fields.push(field);
}
});
return true; //exit early the iteration of this.models
});
// change product.product fields - add name and attribute_value_ids
models.load_fields("product.product", ['name', 'attribute_value_ids']);
//Add our new models //Add our new models
models.PosModel.prototype.models.push({ models.PosModel.prototype.models.push({
@ -517,7 +515,11 @@ odoo.define("pos_product_template.pos_product_template", function(require){
display_default_code: false, display_default_code: false,
};}, };},
loaded: function(self, templates){ loaded: function(self, templates){
if (Object.keys(self.db.product_by_id).length > 0) {
self.db.add_templates(templates); self.db.add_templates(templates);
} else {
self.db.raw_templates = templates;
}
}, },
}, },
{ {
@ -540,6 +542,7 @@ odoo.define("pos_product_template.pos_product_template", function(require){
self.db.add_product_attribute_values(values); self.db.add_product_attribute_values(values);
}, },
}); });
return { return {
'SelectVariantPopupWidget': SelectVariantPopupWidget, 'SelectVariantPopupWidget': SelectVariantPopupWidget,
'VariantListWidget': VariantListWidget, 'VariantListWidget': VariantListWidget,

Loading…
Cancel
Save