Avoid DeprecationWarning for using getitem on Model instance

issue4844
review16401002
This commit is contained in:
Cédric Krier
2015-07-01 19:33:15 +02:00
parent 76f3fa89c9
commit 73a0627467
+4 -5
View File
@@ -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