Set Decimal precision of default context from environment variable

This is placed in the trytond __init__.py because the default context must be
set prior to any start of thread. And thus it can only be set via environment.

Closes #13572
This commit is contained in:
Cédric Krier
2024-10-08 16:34:37 +02:00
parent c1e41fdfa2
commit 120e315bec
3 changed files with 8 additions and 0 deletions
+1
View File
@@ -1,3 +1,4 @@
* Set Decimal precision of default context from TRYTOND_DECIMAL_PREC
* Replace usage of docstring of Model by __string__ attribute
* Rename ir.model.field 'field_description' into 'string'
* Replace docstring of models by __string__
+4
View File
@@ -1,5 +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.
import decimal
import os
import time
import warnings
@@ -40,3 +42,5 @@ def default_user_agent(name="Tryton"):
if requests_utils:
requests_utils.default_user_agent = default_user_agent
decimal.DefaultContext.prec = int(os.environ.get('TRYTOND_DECIMAL_PREC', 28))
+3
View File
@@ -65,6 +65,9 @@ def get_parser():
parser.add_argument(
"--logconf", dest="logconf", default=logging_config, metavar='FILE',
help="set logging configuration file (ConfigParser format)")
parser.epilog = (
"The default Decimal precision can be specified in the "
"TRYTOND_DECIMAL_PREC environment variable.")
return parser