From 76eb8fe87085522719a2d48a279bf55d01a0fcfc Mon Sep 17 00:00:00 2001 From: higo-odoo Date: Wed, 26 Jul 2023 11:04:02 +0000 Subject: [PATCH] [FIX] loyalty: unable to open partner view Step to Reproduce at Runbot: -> Install Coupons & Loyalty and Contacts Apps -> Open Contacts form view -> AccessError telling you that you cannot read loyalty program & cards See this video url: https://watch.screencastify.com/v/ygI1wjVyP5xo5tWTzeST closes odoo/odoo#130092 Part-of: #107375 X-original-commit: 4c31ef775579b6c7163c91fa2069fcc64819f940 Signed-off-by: Victor Feyens (vfe) --- addons/loyalty/models/res_partner.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/addons/loyalty/models/res_partner.py b/addons/loyalty/models/res_partner.py index c2c56f256cf..8abc5ce918e 100644 --- a/addons/loyalty/models/res_partner.py +++ b/addons/loyalty/models/res_partner.py @@ -7,11 +7,14 @@ class ResPartner(models.Model): loyalty_card_count = fields.Integer( string="Active loyalty cards", - compute='_compute_count_active_cards') + compute='_compute_count_active_cards', + compute_sudo=True, + groups='base.group_user') def _compute_count_active_cards(self): loyalty_groups = self.env['loyalty.card']._read_group( domain=[ + '|', ('company_id', '=', False), ('company_id', 'in', self.env.companies.ids), ('partner_id', 'in', self.with_context(active_test=False)._search([('id', 'child_of', self.ids)])), ('points', '>', '0'), ('program_id.active', '=', 'True'),