diff options
| author | Richard Mathot <rim@odoo.com> | 2015-12-23 12:35:05 +0100 |
|---|---|---|
| committer | Richard Mathot <rim@odoo.com> | 2015-12-29 09:05:01 +0100 |
| commit | c9ed8aec914409deff7ff8d7d44254b3e9854dff (patch) | |
| tree | 7ac398f5d13ad7193c4c5242d056c6ebc8ed2f07 | |
| parent | a4ddfe0b286ac1afde0c6c9b7dd3f6c25cb1a3de (diff) | |
[IMP] XML import: float values are not passed as strings anymore
When you import a record from a XML file, values passed to float fields
are not casted as floats.
Eg: ``<field name="price">1.0</field>`` is parsed as '1.0' string.
The method _update from ir_model.py seems to accept these "fake floats"
strings BUT, if you override write() in a module, you can't guess that
values meant to be written in a float field are actually strings
Eg: The override of write() in sale.order.line expects a float and crash
at second install. (try twice `-i sale` in a 9.0 database)
In order to fix this, we apply the same reasoning than for integers
(two lines above).
| -rw-r--r-- | openerp/tools/convert.py | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/openerp/tools/convert.py b/openerp/tools/convert.py index 80540a98f2d..39976b11233 100644 --- a/openerp/tools/convert.py +++ b/openerp/tools/convert.py @@ -704,6 +704,8 @@ form: module.record_id""" % (xml_id,) if f_name in model._fields: if model._fields[f_name].type == 'integer': f_val = int(f_val) + elif model._fields[f_name].type in ['float', 'monetary']: + f_val = float(f_val) res[f_name] = f_val id = self.pool['ir.model.data']._update(cr, self.uid, rec_model, self.module, res, rec_id or False, not self.isnoupdate(data_node), noupdate=self.isnoupdate(data_node), mode=self.mode, context=rec_context ) |
