From c9ed8aec914409deff7ff8d7d44254b3e9854dff Mon Sep 17 00:00:00 2001 From: Richard Mathot Date: Wed, 23 Dec 2015 12:35:05 +0100 Subject: [PATCH] [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: ``1.0`` 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). --- openerp/tools/convert.py | 2 ++ 1 file changed, 2 insertions(+) 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 )