[FIX] yaml tests: extra key in on_change result isn't that bad.
authorDenis Ledoux <dle@odoo.com>
Fri, 8 Aug 2014 09:40:30 +0000 (11:40 +0200)
committerDenis Ledoux <dle@odoo.com>
Fri, 8 Aug 2014 09:40:30 +0000 (11:40 +0200)
In the return result of an on_change, having keys which are not ine the view is not that bad, it is not an actual problem.

Display warning instead of asserting all the keys are in the views.

openerp/tools/yaml_import.py

index 3172caa..8f98573 100644 (file)
@@ -449,10 +449,13 @@ class YamlInterpreter(object):
                     args = map(lambda x: eval(x, ctx), match.group(2).split(','))
                     result = getattr(model, match.group(1))(self.cr, SUPERUSER_ID, [], *args)
                     for key, val in (result or {}).get('value', {}).items():
-                        assert key in fg, "The returning field '%s' from your on_change call '%s' does not exist either on the object '%s', either in the view '%s' used for the creation" % (key, match.group(1), model._name, view_info['name'])
-                        record_dict[key] = process_val(key, val)
-                        #if (key in fields) and record_dict[key] == process_val(key, val):
-                        #    print '*** You can remove these lines:', key, val
+                        if key in fg:
+                            record_dict[key] = process_val(key, val)
+                        else:
+                            _logger.warning("The returning field '%s' from your on_change call '%s'"
+                                            " does not exist either on the object '%s', either in"
+                                            " the view '%s'",
+                                            key, match.group(1), model._name, view_info['name'])
                 else:
                     nodes = list(el) + nodes
         else: