[FIX] base_action_rule: do not force registry reload when writing on a rule unless really needed
Executing a rule always updates the `last_run` value, which would always force a useless registry reload to occur. Only signal the change if the rule applies to a model that was not previoulsy monitored for base action rules.
This commit is contained in:
parent
5d77de54e5
commit
ff8b843b18
|
@ -193,6 +193,7 @@ class base_action_rule(osv.osv):
|
||||||
""" Wrap the methods `create` and `write` of the models specified by
|
""" Wrap the methods `create` and `write` of the models specified by
|
||||||
the rules given by `ids` (or all existing rules if `ids` is `None`.)
|
the rules given by `ids` (or all existing rules if `ids` is `None`.)
|
||||||
"""
|
"""
|
||||||
|
updated = False
|
||||||
if ids is None:
|
if ids is None:
|
||||||
ids = self.search(cr, SUPERUSER_ID, [])
|
ids = self.search(cr, SUPERUSER_ID, [])
|
||||||
for action_rule in self.browse(cr, SUPERUSER_ID, ids):
|
for action_rule in self.browse(cr, SUPERUSER_ID, ids):
|
||||||
|
@ -202,20 +203,21 @@ class base_action_rule(osv.osv):
|
||||||
model_obj.create = self._wrap_create(model_obj.create, model)
|
model_obj.create = self._wrap_create(model_obj.create, model)
|
||||||
model_obj.write = self._wrap_write(model_obj.write, model)
|
model_obj.write = self._wrap_write(model_obj.write, model)
|
||||||
model_obj.base_action_ruled = True
|
model_obj.base_action_ruled = True
|
||||||
return True
|
updated = True
|
||||||
|
return updated
|
||||||
|
|
||||||
def create(self, cr, uid, vals, context=None):
|
def create(self, cr, uid, vals, context=None):
|
||||||
res_id = super(base_action_rule, self).create(cr, uid, vals, context=context)
|
res_id = super(base_action_rule, self).create(cr, uid, vals, context=context)
|
||||||
self._register_hook(cr, [res_id])
|
if self._register_hook(cr, [res_id]):
|
||||||
openerp.modules.registry.RegistryManager.signal_registry_change(cr.dbname)
|
openerp.modules.registry.RegistryManager.signal_registry_change(cr.dbname)
|
||||||
return res_id
|
return res_id
|
||||||
|
|
||||||
def write(self, cr, uid, ids, vals, context=None):
|
def write(self, cr, uid, ids, vals, context=None):
|
||||||
if isinstance(ids, (int, long)):
|
if isinstance(ids, (int, long)):
|
||||||
ids = [ids]
|
ids = [ids]
|
||||||
super(base_action_rule, self).write(cr, uid, ids, vals, context=context)
|
super(base_action_rule, self).write(cr, uid, ids, vals, context=context)
|
||||||
self._register_hook(cr, ids)
|
if self._register_hook(cr, ids):
|
||||||
openerp.modules.registry.RegistryManager.signal_registry_change(cr.dbname)
|
openerp.modules.registry.RegistryManager.signal_registry_change(cr.dbname)
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def onchange_model_id(self, cr, uid, ids, model_id, context=None):
|
def onchange_model_id(self, cr, uid, ids, model_id, context=None):
|
||||||
|
|
Loading…
Reference in New Issue