From 23972a52b037bfe977273d657e2faeb591a16aa0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thibault=20Delavall=C3=A9e?= Date: Tue, 21 Apr 2015 13:41:04 +0200 Subject: [PATCH] [FIX] tools: yaml_import: filter returned values of _create_record. Commit 81364790b91b52f00333dd17975a00e48dd9424d added default values for all fields present in the view to emulate. However some fields present in the view are not stored and should not be sent to create. This bug appears with function field in new API that are not stored. Using the Yaml import generated warning, for example for fields like alias_domain that is a not stored computed field. --- openerp/tools/yaml_import.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/openerp/tools/yaml_import.py b/openerp/tools/yaml_import.py index bdb0cb18ee1..90bf3da4bc8 100644 --- a/openerp/tools/yaml_import.py +++ b/openerp/tools/yaml_import.py @@ -487,6 +487,7 @@ class YamlInterpreter(object): if key not in fields: # do not shadow values explicitly set in yaml. record_dict[key] = process_val(key, val) + # locals_dict.update(record_dict) else: _logger.debug("The returning field '%s' from your on_change call '%s'" " does not exist either on the object '%s', either in" @@ -502,6 +503,11 @@ class YamlInterpreter(object): continue field_value = self._eval_field(model, field_name, expression, parent=record_dict, default=False, context=context) record_dict[field_name] = field_value + + # filter returned values; indeed the last modification in the import process have added a default + # value for all fields in the view; however some fields present in the view are not stored and + # should not be sent to create. This bug appears with not stored function fields in the new API. + record_dict = dict((key, record_dict.get(key)) for key in record_dict if (key in model._columns or key in model._inherit_fields)) return record_dict def process_ref(self, node, field=None):