From 89c4d8b5de49e62fc68be0b3bf4f71967265f4ea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Thu, 17 Jul 2008 19:36:42 +0200 Subject: [PATCH] Use new raise_user_error function --- currency.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/currency.py b/currency.py index aa25425d2e..96eb79f5b4 100644 --- a/currency.py +++ b/currency.py @@ -1,7 +1,7 @@ #This file is part of Tryton. The COPYRIGHT file at the top level of this repository contains the full copyright notices and license terms. "Currency" -from trytond.osv import fields, OSV, ExceptOSV +from trytond.osv import fields, OSV import time from decimal import Decimal import datetime @@ -23,6 +23,9 @@ class Currency(OSV): def __init__(self): super(Currency, self).__init__() self._order.insert(0, ('code', 'ASC')) + self._error_messages.update({ + 'no_rate': 'No rate found for the currency: %s at the date: %s', + }) def default_active(self, cursor, user, context=None): return True @@ -109,9 +112,8 @@ class Currency(OSV): name = from_currency.name else: name = to_currency.name - raise ExceptOSV('UserError', 'No rate found \n' \ - 'for the currency: %s \n' \ - 'at the date: %s' % (name, date)) + self.raise_user_error(cursor, 'no_rate', (name, date), + context=context) if round: return self.round(cursor, user, to_currency, amount * to_currency.rate / from_currency.rate)