From 9274dfc44e3109b7696bfbf8261f58651d59a39d Mon Sep 17 00:00:00 2001 From: Nicolas Martinelli Date: Mon, 25 Feb 2019 13:17:24 +0000 Subject: [PATCH] [FIX] product: pricelist based on cost - Create 2 companies C1 (USD) and C2 (EUR) - Create 2 products P1 and P2 P1: company: C1; cost: 50 P2: company: C2; cost: 50 - Make sure to define the cost in both companies since it is a property field (set it to 50 in all cases) - Update the currency rates for both companies - Create a pricelist in EUR, with a price based on the cost price. - Create a SO in C1, select the pricelist previously created - Add P1 and P2 The unit price for P1 is converted, while the unit price for P2 is 50. This is not correct: both cost prices are set to 50, so the unit price should be identical. This is because the pricelist always assumes that the price retrieved is in the product currency. In this case, this is not correct: the price retrieved is in the company currency, since the cost price is in the company currency. Closes #30616 opw-1934443 closes odoo/odoo#31402 --- addons/product/models/product_pricelist.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/addons/product/models/product_pricelist.py b/addons/product/models/product_pricelist.py index aa267ba5b7e..57594a28ac9 100644 --- a/addons/product/models/product_pricelist.py +++ b/addons/product/models/product_pricelist.py @@ -241,7 +241,11 @@ class Pricelist(models.Model): break # Final price conversion into pricelist currency if suitable_rule and suitable_rule.compute_price != 'fixed' and suitable_rule.base != 'pricelist': - price = product.currency_id.compute(price, self.currency_id, round=False) + if suitable_rule.base == 'standard_price': + # The cost of the product is always in the company currency + price = product.cost_currency_id.compute(price, self.currency_id, round=False) + else: + price = product.currency_id.compute(price, self.currency_id, round=False) results[product.id] = (price, suitable_rule and suitable_rule.id or False)