From e2cc2c3ce29abb14e7911290c2ae8c4d45c0725d Mon Sep 17 00:00:00 2001 From: "Andrea Grazioso (agr-odoo)" Date: Mon, 8 Feb 2021 11:25:14 +0000 Subject: [PATCH] [FIX] point_of_sale: fix variant price in pricelist Create a product with variants attributes that NEVER create variants. Configure Variants to add some extra-prices (1$) to some variants. In POS settings activate "Product Configurator" and "Advanced Pricelists", add the public pricelist and one that applies 50% to the product. Open a session and select the product created (say price = 1$) Select the attributes, the extra-price is added to the product (say the total price now is 2$). Change pricelist from public to 50% and the order line will show our product = 1@50% + 1 = 1.50, not applying the pricelist to the extra-price opw-2439445 closes odoo/odoo#66251 X-original-commit: ee451c61550fc7577efa42e05f8d0094cb1513e1 Signed-off-by: agr-odoo --- addons/point_of_sale/static/src/js/models.js | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/addons/point_of_sale/static/src/js/models.js b/addons/point_of_sale/static/src/js/models.js index 08525e06667..826cb57c088 100644 --- a/addons/point_of_sale/static/src/js/models.js +++ b/addons/point_of_sale/static/src/js/models.js @@ -1511,7 +1511,7 @@ exports.Product = Backbone.Model.extend({ // product.pricelist.item records are loaded with a search_read // and were automatically sorted based on their _order by the // ORM. After that they are added in this order to the pricelists. - get_price: function(pricelist, quantity){ + get_price: function(pricelist, quantity, price_extra){ var self = this; var date = moment().startOf('day'); @@ -1540,6 +1540,9 @@ exports.Product = Backbone.Model.extend({ }); var price = self.lst_price; + if (price_extra){ + price += price_extra; + } _.find(pricelist_items, function (rule) { if (rule.min_quantity && quantity < rule.min_quantity) { return false; @@ -1767,7 +1770,7 @@ exports.Orderline = Backbone.Model.extend({ // just like in sale.order changing the quantity will recompute the unit price if(! keep_price && ! this.price_manually_set){ - this.set_unit_price(this.product.get_price(this.order.pricelist, this.get_quantity()) + this.get_price_extra()); + this.set_unit_price(this.product.get_price(this.order.pricelist, this.get_quantity(), this.get_price_extra())); this.order.fix_tax_included_price(this); } this.trigger('change', this); @@ -2936,7 +2939,7 @@ exports.Order = Backbone.Model.extend({ return ! line.price_manually_set; }); _.each(lines_to_recompute, function (line) { - line.set_unit_price(line.product.get_price(self.pricelist, line.get_quantity()) + line.get_price_extra()); + line.set_unit_price(line.product.get_price(self.pricelist, line.get_quantity(), line.get_price_extra())); self.fix_tax_included_price(line); }); this.trigger('change'); @@ -2996,7 +2999,7 @@ exports.Order = Backbone.Model.extend({ if (options.price_extra !== undefined){ orderline.price_extra = options.price_extra; - orderline.set_unit_price(orderline.get_unit_price() + options.price_extra); + orderline.set_unit_price(orderline.product.get_price(this.pricelist, orderline.get_quantity(), options.price_extra)); this.fix_tax_included_price(orderline); }