Follow-up on this post: https://www.odoo.com/nl_NL/forum/help-1/product-view-show-price-of-a-specific-pricelist-287616
I now have the following code:
for record in self:
pricelist = self.env['product.pricelist'].search([('name', '=', 'Horeca')], limit=1)
product_variant = record.product_variant_id
record["x_studio_horeca_price"] = pricelist._get_product_price(product_variant, 1.0) if pricelist and product_variant else 0.0
This works great in the product view, but if I have 2 variants, only the base variant has the correct price. With the second variant, where I add a certain amount, the pricelist price is calculated on the original price, not the variant sale price.
Any ideas on how to solve this? Should I create a separate field for the variants or can I adapt the existing code ?