[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
This commit is contained in:
Nicolas Martinelli
2019-02-25 13:58:02 +00:00
parent 950d0f1849
commit 9274dfc44e
+5 -1
View File
@@ -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)