[FIX] base_action_rule: Make sure model exists before trying to wrap hooks
authorSandy Carter <sandy.carter@savoirfairelinux.com>
Thu, 23 Oct 2014 21:45:55 +0000 (17:45 -0400)
committerDenis Ledoux <dle@odoo.com>
Thu, 30 Oct 2014 09:02:04 +0000 (10:02 +0100)
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>

addons/base_action_rule/base_action_rule.py

index 98d533b..398bf00 100644 (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