Skip to content

Commit

Permalink
[FIX] openerp: monetary not xmlrpc serializable
Browse files Browse the repository at this point in the history
Since 1ba9104 monetary fields values could be represented by a
float_precision which is aimed as an improvment for digit precision when
saving a monetary field value to the database.

xmlrpclib (we are using to serialze the response) is handling some
common datatypes, but for custom one we would need to register it with
how it needs to be serialized.

This commit add a convert_to_read method to the Monetary field so when
reading monetary fields value we get the float numbers and not the
float_precision ones.

The float_precision is needed when saving, so it is alright to have float
when reading.

fixes odoo#13857
closes odoo#14125

opw-692373
  • Loading branch information
nle-odoo committed Nov 8, 2016
1 parent 929cfc2 commit 3c3cced
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions openerp/fields.py
Original file line number Diff line number Diff line change
Expand Up @@ -1185,6 +1185,13 @@ def convert_to_cache(self, value, record, validate=True):
return float_precision(value, currency.decimal_places)
return float(value or 0.0)

def convert_to_read(self, value, record, use_name_get=True):
# float_precision values are not supported in pure XMLRPC
return float(value)

def convert_to_write(self, value, record):
return value


class _String(Field):
""" Abstract class for string fields. """
Expand Down

0 comments on commit 3c3cced

Please sign in to comment.