From 943ffb7a5d171314a5ed223160bfa24f2c2875fe Mon Sep 17 00:00:00 2001 From: Emanuel Cino Date: Tue, 20 Jun 2023 07:36:43 +0200 Subject: [PATCH] [IMP] Apply suggested changes from FrankC013 to put price_extra to 0.0 --- .../models/product_product.py | 29 ++++++++++++++----- 1 file changed, 21 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..f02b69181 100644 --- a/product_variant_sale_price/models/product_product.py +++ b/product_variant_sale_price/models/product_product.py @@ -27,10 +27,26 @@ 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 +87,8 @@ 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