[FIX] ir.rule: use rules at most once (#15843)

When a user belongs to multiple groups, and an ir.rule is applicable for some of
them, the rule is added multiple times in the domain. Just do it once. This
makes the query shorter and easier to debug.
This commit is contained in:
SEINLET Nicolas 2017-04-11 09:27:58 +02:00 committed by Raphael Collet
parent 8f7791fcee
commit ded636eae1
1 changed files with 2 additions and 3 deletions

View File

@ -129,9 +129,8 @@ class ir_rule(osv.osv):
# read 'domain' as UID to have the correct eval context for the rule.
rule_domain = self.read(cr, uid, [rule.id], ['domain'])[0]['domain']
dom = expression.normalize_domain(rule_domain)
for group in rule.groups:
if group in user.groups_id:
group_domains.setdefault(group, []).append(dom)
if rule.groups & user.groups_id:
group_domains.setdefault(rule.groups[0], []).append(dom)
if not rule.groups:
global_domains.append(dom)
# combine global domains and group domains