[FIX] base_action_rule: Make sure model exists before trying to wrap hooks

In certain cases, before running an update unregistered models will try to
register hooks. Trying to wrap create and write on these will cause
AttributeError on model_obj which would be None

Signed-off-by: Sandy Carter <sandy.carter@savoirfairelinux.com>
This commit is contained in:
Sandy Carter 2014-10-23 17:45:55 -04:00 committed by Denis Ledoux
parent 2b2ec07435
commit 1661cf53e9
1 changed files with 1 additions and 1 deletions

View File

@ -199,7 +199,7 @@ class base_action_rule(osv.osv):
for action_rule in self.browse(cr, SUPERUSER_ID, ids):
model = action_rule.model_id.model
model_obj = self.pool.get(model)
if not hasattr(model_obj, 'base_action_ruled'):
if model_obj and not hasattr(model_obj, 'base_action_ruled'):
model_obj.create = self._wrap_create(model_obj.create, model)
model_obj.write = self._wrap_write(model_obj.write, model)
model_obj.base_action_ruled = True