[IMP] attempt to improve yaml test message in order to make its errors somewhat less cryptic

and make it easier to understand why it's whining.

bzr revid: xmo@openerp.com-20140108133722-9ac9l3w7wij0pl1i
This commit is contained in:
Xavier Morel 2014-01-08 14:37:22 +01:00
parent 4a3a7130fb
commit 6aa79d8cb3
1 changed files with 8 additions and 2 deletions

View File

@ -328,7 +328,7 @@ class YamlInterpreter(object):
if config.get('import_partial'):
self.cr.commit()
def _create_record(self, model, fields, view_info=False, parent={}, default=True):
def _create_record(self, model, fields, view_info=None, parent={}, default=True):
"""This function processes the !record tag in yalm files. It simulates the record creation through an xml
view (either specified on the !record tag or the default one for this object), including the calls to
on_change() functions, and sending only values for fields that aren't set as readonly.
@ -447,7 +447,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'])
assert key in fg, (
"The field %r returned from the onchange call %r "
"does not exist in the source view %r (of object "
"%r). This field will be ignored (and thus not "
"populated) when clients saves the new record" % (
key, match.group(1), view_info['name'], model._name
))
if key not in fields:
# do not shadow values explicitly set in yaml.
record_dict[key] = process_val(key, val)