From 187a929c0540bddb4e622d41ad58b9eaf8ee9817 Mon Sep 17 00:00:00 2001 From: Emanuel Cino Date: Thu, 13 Jul 2023 16:11:02 +0200 Subject: [PATCH] [IMP] Apply suggested changes from FrankC013 to put price_extra to 0.0 --- .../models/product_product.py | 43 +++++++++++++++---- 1 file changed, 35 insertions(+), 8 deletions(-) diff --git a/product_variant_sale_price/models/product_product.py b/product_variant_sale_price/models/product_product.py index ac79a046f..c96571ac8 100644 --- a/product_variant_sale_price/models/product_product.py +++ b/product_variant_sale_price/models/product_product.py @@ -27,10 +27,39 @@ def write(self, vals): template._update_fix_price(vals) return res + def _get_combination_info( + self, + combination=False, + product_id=False, + add_qty=1, + pricelist=False, + parent_combination=False, + only_template=False, + ): + res = super()._get_combination_info( + combination, + product_id, + add_qty, + pricelist, + parent_combination, + only_template, + ) + res["price_extra"] = 0.0 + return res + class ProductProduct(models.Model): _inherit = "product.product" + lst_price = fields.Float( + compute="_compute_lst_price", + inverse="_inverse_product_lst_price", + ) + list_price = fields.Float( + compute="_compute_list_price", + ) + fix_price = fields.Float() + @api.depends("fix_price") def _compute_lst_price(self): uom_model = self.env["uom.uom"] @@ -71,11 +100,9 @@ def _inverse_product_lst_price(self): ).list_price = min(fix_prices) product.write(vals) - lst_price = fields.Float( - compute="_compute_lst_price", - inverse="_inverse_product_lst_price", - ) - list_price = fields.Float( - compute="_compute_list_price", - ) - fix_price = fields.Float() + def _compute_product_price_extra(self): + """the sale.order.line module calculates the price_unit by adding + the value of price_extra and this can generate inconsistencies + if the field has old data stored.""" + for product in self: + product.price_extra = 0.0