[FIX] base: set default currency rate at date

This commit is contained in:
Christophe Simonis
2018-07-13 17:08:58 +02:00
parent 965b2b7478
commit af4df80283
+3 -2
View File
@@ -46,11 +46,12 @@ class Currency(models.Model):
]
def _get_rates(self, company, date):
query = """SELECT c.id, (SELECT r.rate FROM res_currency_rate r
query = """SELECT c.id,
COALESCE((SELECT r.rate FROM res_currency_rate r
WHERE r.currency_id = c.id AND r.name <= %s
AND (r.company_id IS NULL OR r.company_id = %s)
ORDER BY r.company_id, r.name DESC
LIMIT 1) AS rate
LIMIT 1), 1.0) AS rate
FROM res_currency c
WHERE c.id IN %s"""
self._cr.execute(query, (date, company.id, tuple(self.ids)))