changeset f27cde11788b in trytond:default
details: https://hg.tryton.org/trytond?cmd=changeset&node=f27cde11788b
description:
        Use bigdecimal tag for XML-RPC

        issue10734
        review355491002
diffstat:

 CHANGELOG                       |   1 +
 trytond/protocols/xmlrpc.py     |   7 +++----
 trytond/tests/test_protocols.py |  18 ++++++++++++++++++
 3 files changed, 22 insertions(+), 4 deletions(-)

diffs (53 lines):

diff -r 6704b2faa950 -r f27cde11788b CHANGELOG
--- a/CHANGELOG Thu Sep 23 10:19:03 2021 +0200
+++ b/CHANGELOG Thu Sep 23 10:22:01 2021 +0200
@@ -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 -r 6704b2faa950 -r f27cde11788b trytond/protocols/xmlrpc.py
--- a/trytond/protocols/xmlrpc.py       Thu Sep 23 10:19:03 2021 +0200
+++ b/trytond/protocols/xmlrpc.py       Thu Sep 23 10:22:01 2021 +0200
@@ -23,10 +23,9 @@
 
 
 def dump_decimal(self, value, write):
-    value = {'__class__': 'Decimal',
-        'decimal': str(value),
-        }
-    self.dump_struct(value, write)
+    write('<value><bigdecimal>')
+    write(str(Decimal(value)))
+    write('</bigdecimal></value>')
 
 
 def dump_date(self, value, write):
diff -r 6704b2faa950 -r f27cde11788b trytond/tests/test_protocols.py
--- a/trytond/tests/test_protocols.py   Thu Sep 23 10:19:03 2021 +0200
+++ b/trytond/tests/test_protocols.py   Thu Sep 23 10:22:01 2021 +0200
@@ -101,6 +101,24 @@
         result, = result
         self.assertEqual(value, result)
 
+    def test_decimal_class_load(self):
+        "Test load Decimal as __class__"
+        s = """<params><param><value>
+            <struct>
+                <member>
+                    <name>__class__</name>
+                    <value><string>Decimal</string></value>
+                </member>
+                <member>
+                    <name>decimal</name>
+                    <value><string>3.141592653589793</string></value>
+                </member>
+            </struct>
+            </value></param></params>"""
+        result, _ = client.loads(s)
+        result, = result
+        self.assertEqual(result, Decimal('3.141592653589793'))
+
 
 def suite():
     suite_ = unittest.TestSuite()

Reply via email to