From 6b610114c4ee1b6aedc02fa17fbf6290c8dfd800 Mon Sep 17 00:00:00 2001 From: eLBati Date: Fri, 5 Feb 2016 12:44:07 +0100 Subject: [PATCH] [FIX] keep _register_hook's signature and call super https://github.com/OCA/server-tools/pull/340 --- base_field_validator/models/ir_model.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/base_field_validator/models/ir_model.py b/base_field_validator/models/ir_model.py index fd5bd8684..1042cc509 100644 --- a/base_field_validator/models/ir_model.py +++ b/base_field_validator/models/ir_model.py @@ -57,13 +57,9 @@ class IrModel(orm.Model): return wrapper - def _register_hook(self, cr, ids=None): + def _field_validator_hook(self, cr, ids): """ Wrap the methods `create` and `write` of the model """ - res = super(IrModel, self)._register_hook(cr) - if ids is None: - ids = self.search( - cr, SUPERUSER_ID, [('validator_line_ids', '!=', False)]) updated = False for model in self.browse(cr, SUPERUSER_ID, ids): if model.validator_line_ids: @@ -81,19 +77,23 @@ class IrModel(orm.Model): if updated: openerp.modules.registry.RegistryManager.\ signal_registry_change(cr.dbname) - return res + return True + + def _register_hook(self, cr, ids=None): + self._field_validator_hook(cr, self.search(cr, SUPERUSER_ID, [])) + return super(IrModel, self)._register_hook(cr) def create(self, cr, uid, vals, context=None): res_id = super(IrModel, self).create( cr, uid, vals, context=context) - self._register_hook(cr, [res_id]) + self._field_validator_hook(cr, [res_id]) return res_id def write(self, cr, uid, ids, vals, context=None): if isinstance(ids, (int, long)): ids = [ids] res = super(IrModel, self).write(cr, uid, ids, vals, context=context) - self._register_hook(cr, ids) + self._field_validator_hook(cr, ids) return res