diff --git a/doc/topics/install.rst b/doc/topics/install.rst index be508ae30f..4cfb44d0b2 100644 --- a/doc/topics/install.rst +++ b/doc/topics/install.rst @@ -20,6 +20,7 @@ Prerequisites * Optional: unoconv http://dag.wieers.com/home-made/unoconv/) * Optional: sphinx (http://sphinx.pocoo.org/) * Optional: simplejson (http://undefined.org/python/#simplejson) + * Optional: cdecimal (http://www.bytereef.org/mpdecimal/index.html) Install Tryton ============== diff --git a/setup.py b/setup.py index 6046e70bfe..34e7a4214d 100644 --- a/setup.py +++ b/setup.py @@ -71,6 +71,7 @@ setup(name=PACKAGE, 'graphviz': ['pydot'], 'timezone': ['pytz'], 'simplejson': ['simplejson'], + 'cdecimal': ['cdecimal'], }, zip_safe=False, test_suite='trytond.tests', diff --git a/trytond/config.py b/trytond/config.py index 0cdb678dbf..098462d650 100644 --- a/trytond/config.py +++ b/trytond/config.py @@ -1,6 +1,16 @@ #This file is part of Tryton. The COPYRIGHT file at the top level of #this repository contains the full copyright notices and license terms. -import ConfigParser, os, sys +import sys +try: + import cdecimal + # Use cdecimal globally + if 'decimal' not in sys.modules: + sys.modules['decimal'] = cdecimal +except ImportError: + import decimal + sys.modules['cdecimal'] = decimal +import os +import ConfigParser def get_hostname(netloc): if '[' in netloc and ']' in netloc: diff --git a/trytond/tests/test_exportdata.py b/trytond/tests/test_exportdata.py index 568f537dba..64984f76c4 100644 --- a/trytond/tests/test_exportdata.py +++ b/trytond/tests/test_exportdata.py @@ -2,6 +2,14 @@ # -*- coding: utf-8 -*- #This file is part of Tryton. The COPYRIGHT file at the top level of #this repository contains the full copyright notices and license terms. +import sys +try: + import cdecimal + if 'decimal' not in sys.modules: + sys.modules['decimal'] = cdecimal +except ImportError: + import decimal + sys.modules['cdecimal'] = decimal import unittest from decimal import Decimal import datetime diff --git a/trytond/tests/test_fields.py b/trytond/tests/test_fields.py index cf1705e39e..b068a7a121 100644 --- a/trytond/tests/test_fields.py +++ b/trytond/tests/test_fields.py @@ -2,6 +2,14 @@ # -*- coding: utf-8 -*- #This file is part of Tryton. The COPYRIGHT file at the top level of #this repository contains the full copyright notices and license terms. +import sys +try: + import cdecimal + if 'decimal' not in sys.modules: + sys.modules['decimal'] = cdecimal +except ImportError: + import decimal + sys.modules['cdecimal'] = decimal import unittest import datetime from decimal import Decimal