From 9ae04f3e68f639f0eab7e51f2f123c01bdd51146 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Thu, 23 Sep 2021 10:22:01 +0200 Subject: [PATCH] Use bigdecimal tag for XML-RPC issue10734 review355491002 --- CHANGELOG | 1 + trytond/protocols/xmlrpc.py | 7 +++---- trytond/tests/test_protocols.py | 18 ++++++++++++++++++ 3 files changed, 22 insertions(+), 4 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 746239b64d..c58b26e1ce 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,4 @@ +* Use bigdecimal tag for XML-RPC * Use tuple in Dict value instead of list * Do not set record name on title of report get_email * Add node to id of status diff --git a/trytond/protocols/xmlrpc.py b/trytond/protocols/xmlrpc.py index e4cbcafa16..f7426b8e09 100644 --- a/trytond/protocols/xmlrpc.py +++ b/trytond/protocols/xmlrpc.py @@ -23,10 +23,9 @@ logger = logging.getLogger(__name__) def dump_decimal(self, value, write): - value = {'__class__': 'Decimal', - 'decimal': str(value), - } - self.dump_struct(value, write) + write('') + write(str(Decimal(value))) + write('') def dump_date(self, value, write): diff --git a/trytond/tests/test_protocols.py b/trytond/tests/test_protocols.py index e253b3c3a1..55cddce5e5 100644 --- a/trytond/tests/test_protocols.py +++ b/trytond/tests/test_protocols.py @@ -101,6 +101,24 @@ class XMLTestCase(DumpsLoadsMixin, unittest.TestCase): result, = result self.assertEqual(value, result) + def test_decimal_class_load(self): + "Test load Decimal as __class__" + s = """ + + + __class__ + Decimal + + + decimal + 3.141592653589793 + + + """ + result, _ = client.loads(s) + result, = result + self.assertEqual(result, Decimal('3.141592653589793')) + def suite(): suite_ = unittest.TestSuite()