diff --git a/product_sale_price_from_pricelist/models/product_template.py b/product_sale_price_from_pricelist/models/product_template.py index 09ef270..8e80b4e 100644 --- a/product_sale_price_from_pricelist/models/product_template.py +++ b/product_sale_price_from_pricelist/models/product_template.py @@ -55,6 +55,14 @@ class ProductTemplate(models.Model): store=True, ) + # Alias for backward compatibility with pricelist base price computation + last_purchase_price = fields.Float( + string="Last Purchase Price", + compute="_compute_last_purchase_price", + search="_search_last_purchase_price", + store=True, + ) + @api.depends("product_variant_ids.last_purchase_price_updated") def _compute_last_purchase_price_updated(self): for template in self: @@ -139,6 +147,15 @@ class ProductTemplate(models.Model): ("product_variant_ids.last_purchase_price_compute_type", operator, value) ] + @api.depends("last_purchase_price_received") + def _compute_last_purchase_price(self): + """Alias for backward compatibility with pricelist computations.""" + for template in self: + template.last_purchase_price = template.last_purchase_price_received + + def _search_last_purchase_price(self, operator, value): + return [("last_purchase_price_received", operator, value)] + def action_update_list_price(self): """Delegate to product variants.""" return self.product_variant_ids.action_update_list_price()