[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).
This commit is contained in:
Richard Mathot
2015-12-29 09:05:01 +01:00
parent a4ddfe0b28
commit c9ed8aec91
+2
View File
@@ -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 )