From f48c502480db65576e066aa2ae350f8a8c2a76fb Mon Sep 17 00:00:00 2001 From: Guewen Baconnier Date: Tue, 1 Mar 2016 13:50:59 +0100 Subject: [PATCH] Add method to BaseModel only on addon installation --- web_access_rule_buttons/models.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/web_access_rule_buttons/models.py b/web_access_rule_buttons/models.py index a4ef8b18..cb2a774d 100644 --- a/web_access_rule_buttons/models.py +++ b/web_access_rule_buttons/models.py @@ -28,4 +28,11 @@ def check_access_rule_all(self, operations=None): return result -models.BaseModel.check_access_rule_all = check_access_rule_all +# Could be any model, we just use a core model to have a 'register_hook' +class IrModel(models.Model): + _inherit = 'ir.model' + + def _register_hook(self, cr): + # Add method check_access_rule_all for all models + models.BaseModel.check_access_rule_all = check_access_rule_all + return super(IrModel, self)._register_hook(cr)