[FIX] openerp: fix traceback when no field in constrains

In case you don't have 'field', the first 'if' will raise a warning.
In this case the second 'if' will crash with:
    "'NoneType' object has no attribute 'store'"

This commit closes #16146
Courtesy of @kmetaxas
This commit is contained in:
Jeremy Kersten 2017-03-31 11:47:58 +02:00 committed by Jeremy Kersten
parent 7f260ab517
commit d7c765f62f
1 changed files with 1 additions and 1 deletions

View File

@ -750,7 +750,7 @@ class BaseModel(object):
field = cls._fields.get(name)
if not field:
_logger.warning("method %s.%s: @constrains parameter %r is not a field name", cls._name, attr, name)
if not (field.store or field.column and field.column._fnct_inv):
elif not (field.store or field.column and field.column._fnct_inv):
_logger.warning("method %s.%s: @constrains parameter %r is not writeable", cls._name, attr, name)
methods.append(func)