diff --git a/modules/currency/currency.py b/modules/currency/currency.py
index 04b8414a5f..6ac5511d11 100644
--- a/modules/currency/currency.py
+++ b/modules/currency/currency.py
@@ -11,8 +11,8 @@ from sql.functions import NthValue
from trytond.i18n import gettext
from trytond.model import (
- Check, DeactivableMixin, DigitsMixin, Index, ModelSQL, ModelView,
- SymbolMixin, Unique, fields)
+ DeactivableMixin, DigitsMixin, Index, ModelSQL, ModelView, SymbolMixin,
+ Unique, fields)
from trytond.pool import Pool
from trytond.pyson import Eval, If
from trytond.rpc import RPC
@@ -274,7 +274,10 @@ class CurrencyRate(ModelSQL, ModelView):
"Date", required=True,
help="From when the rate applies.")
rate = fields.Numeric(
- "Rate", digits=(rate_decimal * 2, rate_decimal), required=1,
+ "Rate", digits=(rate_decimal * 2, rate_decimal), required=True,
+ domain=[
+ ('rate', '>', 0),
+ ],
help="The floating exchange rate used to convert the currency.")
currency = fields.Many2One('currency.currency', 'Currency',
ondelete='CASCADE',
@@ -288,8 +291,6 @@ class CurrencyRate(ModelSQL, ModelView):
cls._sql_constraints = [
('date_currency_uniq', Unique(t, t.date, t.currency),
'currency.msg_currency_unique_rate_date'),
- ('check_currency_rate', Check(t, t.rate >= 0),
- 'currency.msg_currency_rate_positive'),
]
cls._sql_indexes.add(
Index(
@@ -299,6 +300,14 @@ class CurrencyRate(ModelSQL, ModelView):
order='DESC'))
cls._order.insert(0, ('date', 'DESC'))
+ @classmethod
+ def __register__(cls, module):
+ table_h = cls.__table_handler__(module)
+ super().__register__(module)
+
+ # Migration from 7.2: remove check_currency_rate
+ table_h.drop_constraint('check_currency_rate')
+
@staticmethod
def default_date():
Date = Pool().get('ir.date')
diff --git a/modules/currency/message.xml b/modules/currency/message.xml
index f2a22ab3dd..d5996edfe1 100644
--- a/modules/currency/message.xml
+++ b/modules/currency/message.xml
@@ -9,8 +9,5 @@ this repository contains the full copyright notices and license terms. -->
A currency can only have one rate by date.
-
- A currency rate must be positive.
-
diff --git a/modules/currency/tests/test_module.py b/modules/currency/tests/test_module.py
index 02e28007d7..6c1df33309 100644
--- a/modules/currency/tests/test_module.py
+++ b/modules/currency/tests/test_module.py
@@ -244,7 +244,6 @@ class CurrencyTestCase(ModuleTestCase):
cu1 = create_currency('cu1')
cu2 = create_currency('cu2')
- add_currency_rate(cu1, Decimal('0'))
add_currency_rate(cu2, Decimal('1'))
amount = Decimal("10")