From 73a0627467d2fc79c2e93dc5fc07db7a7db9e6b5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Wed, 1 Jul 2015 19:33:15 +0200 Subject: [PATCH] Avoid DeprecationWarning for using getitem on Model instance issue4844 review16401002 --- currency.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/currency.py b/currency.py index 8af9352807..63d015c07a 100644 --- a/currency.py +++ b/currency.py @@ -159,11 +159,10 @@ class Currency(ModelSQL, ModelView): closer = datetime.date.min res = Decimal('0.0') for rate in self.rates or []: - if 'date' not in rate or 'rate' not in rate: - continue - if rate['date'] <= now and rate['date'] > closer: - res = rate['rate'] - closer = rate['date'] + date = getattr(rate, 'date', now) + if date <= now and date > closer: + res = rate + closer = date return res @staticmethod