diff --git a/product_sale_price_from_pricelist/models/product_template.py b/product_sale_price_from_pricelist/models/product_template.py index 4bb23a4..894de69 100644 --- a/product_sale_price_from_pricelist/models/product_template.py +++ b/product_sale_price_from_pricelist/models/product_template.py @@ -46,6 +46,18 @@ class ProductTemplate(models.Model): company_dependent=True, ) + price_differs = fields.Boolean( + string="Price Differs", compute="_compute_price_differs", store=True + ) + + @api.depends("list_price", "list_price_theoritical") + def _compute_price_differs(self): + for product in self: + product.price_differs = ( + product.list_price != product.list_price_theoritical + and product.last_purchase_price_compute_type != "manual_update" + ) + def _compute_theoritical_price(self): pricelist_obj = self.env["product.pricelist"] pricelist_id = ( @@ -89,7 +101,9 @@ class ProductTemplate(models.Model): template.write( { "list_price_theoritical": price_with_taxes, - "last_purchase_price_updated": True, + "last_purchase_price_updated": ( + price_with_taxes != template.list_price + ), } ) else: diff --git a/product_sale_price_from_pricelist/views/product_view.xml b/product_sale_price_from_pricelist/views/product_view.xml index 1d1a277..2932212 100644 --- a/product_sale_price_from_pricelist/views/product_view.xml +++ b/product_sale_price_from_pricelist/views/product_view.xml @@ -60,8 +60,10 @@ +