[FIX] sale: expense price unit

The company currency is EUR, and GBP rates are:
- 0.8414 at day 1
- 0.8389 at day 2

Then:
- Create a SO in GBP at day 1 and confirm
- Create an expense in GBP at day 2 and choose the analytic account of
  the SO
- Validate the expense and post the journal entries

Problem:
- The amount of the expense is 93 GBP
- The amount of the sale order line is 93.28 GBP

opw-696375
This commit is contained in:
Nicolas Martinelli
2016-12-22 16:13:25 +01:00
parent 7004dc827e
commit 10a9287f2e
+6
View File
@@ -47,6 +47,12 @@ class AccountAnalyticLine(models.Model):
def _get_invoice_price(self, order):
if self.unit_amount == 0.0:
return 0.0
# Prevent unnecessary currency conversion that could be impacted by exchange rate
# fluctuations
if self.currency_id and self.amount_currency and self.currency_id == order.currency_id:
return abs(self.amount_currency / self.unit_amount)
price_unit = abs(self.amount / self.unit_amount)
currency_id = self.company_id.currency_id
if currency_id and currency_id != order.currency_id: