[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 <agr-odoo@users.noreply.github.com>
This commit is contained in:
Andrea Grazioso (agr-odoo)
2021-02-16 11:17:01 +00:00
parent ec0fc57462
commit e2cc2c3ce2
+7 -4
View File
@@ -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);
}