Merge lp:~openerp-dev/openobject-server/6.0-opw-5692-ach into lp:openobject-server/6.0

Proposed by Anup(SerpentCS)
Status: Merged
Approved by: Jay Vora (Serpent Consulting Services)
Approved revision: 3432
Merged at revision: 3457
Proposed branch: lp:~openerp-dev/openobject-server/6.0-opw-5692-ach
Merge into: lp:openobject-server/6.0
Diff against target: 13 lines (+2/-1)
1 file modified
bin/addons/base/ir/ir_rule.py (+2/-1)
To merge this branch: bzr merge lp:~openerp-dev/openobject-server/6.0-opw-5692-ach
Reviewer Review Type Date Requested Status
Lorenzo Battistini (community) Approve
Olivier Dony (Odoo) Approve
Stephane Wirtel (OpenERP) Pending
Jay Vora (Serpent Consulting Services) Pending
Review via email: mp+61101@code.launchpad.net

Description of the change

Hello,

   This fixes the issue. Now the domains of the record rules are being ANDed instead of ORing.

   Please Share your views.

Thanks.

To post a comment you must log in.
3425. By Launchpad Translations on behalf of openerp

Launchpad automatic translations update.

3426. By Launchpad Translations on behalf of openerp

Launchpad automatic translations update.

Revision history for this message
Stefan Rijnhart (Opener) (stefan-opener) wrote :

Hi,

revision <email address hidden> does not solve the problem, and seems to change the meaning of group membership in an unacceptable way. See my comment on the issue:

https://bugs.launchpad.net/openobject-server/+bug/766982/comments/13

Cheers,
Stefan.

Revision history for this message
Olivier Dony (Odoo) (odo-openerp) wrote :

I agree with Stefan, this is definitely not correct. The issue is not about changing the semantics of the combination of rules, it is only about being sure a user does not get rules applied from a group he does not actually belong to.

As Lorenzo explained in the bug report, at line 117 there is an iteration on the rule's groups, but obviously this could include groups the user does not belong to! So we just need to filter out the groups that are irrelevant to the user.

For example, say you have user U1 who belongs to group G1, and say rule R1 is linked to groups G1 and G2. When iterating on R1's groups for user U1, we will see G1 _and_ G2, and consider U1 a member of both groups, which leads to mistakes.

This is better explained with code, so here's an unverified, dumb patch to illustrate the desired result:
=== modified file 'bin/addons/base/ir/ir_rule.py'
--- bin/addons/base/ir/ir_rule.py 2011-03-02 11:08:16 +0000
+++ bin/addons/base/ir/ir_rule.py 2011-05-18 12:25:41 +0000
@@ -115,7 +115,9 @@
         if ids:
             for rule in self.browse(cr, uid, ids):
                 for group in rule.groups:
- group_rule.setdefault(group.id, []).append(rule.id)
+ # filter out irrelevant groups!
+ if uid in [u.id for u in group.users]:
+ group_rule.setdefault(group.id, []).append(rule.id)
                 if not rule.groups:
                   global_rules.append(rule.id)
             global_domain = self.domain_create(cr, uid, global_rules)

review: Needs Fixing
3427. By Launchpad Translations on behalf of openerp

Launchpad automatic translations update.

3428. By Launchpad Translations on behalf of openerp

Launchpad automatic translations update.

3429. By Launchpad Translations on behalf of openerp

Launchpad automatic translations update.

3430. By Launchpad Translations on behalf of openerp

Launchpad automatic translations update.

3431. By Launchpad Translations on behalf of openerp

Launchpad automatic translations update.

Revision history for this message
Lorenzo Battistini (elbati) wrote :

I agree with Olivier and Stefan :-)

Revision history for this message
Stephane Wirtel (OpenERP) (stephane-openerp) wrote :

I asked to Anup to recheck the code of his branch.

Thank you for your feedback.

Stéphane

3432. By Anup(SerpentCS)

[FIX] base : Improved the Group Rule process

Revision history for this message
Anup(SerpentCS) (anup-serpent) wrote :

Hello Everyone,

   I do agree with the discussion. I have corrected my code with the fruitful suggestions provided by you all.

   @Olivier, I have checked by applying the fix suggested by you. It works the way it's desired. Can you please double check the things?

Thanks a lot for your participation.

Revision history for this message
Olivier Dony (Odoo) (odo-openerp) wrote :

This is all good for me now, thanks! :-)

review: Approve
Revision history for this message
Lorenzo Battistini (elbati) wrote :

It works for me ;-)

review: Approve
Revision history for this message
Lorenzo Battistini (elbati) wrote :

Hi there, when will it be merged?

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'bin/addons/base/ir/ir_rule.py'
2--- bin/addons/base/ir/ir_rule.py 2011-03-02 11:08:16 +0000
3+++ bin/addons/base/ir/ir_rule.py 2011-05-23 13:42:00 +0000
4@@ -115,7 +115,8 @@
5 if ids:
6 for rule in self.browse(cr, uid, ids):
7 for group in rule.groups:
8- group_rule.setdefault(group.id, []).append(rule.id)
9+ if uid in [u.id for u in group.users]:
10+ group_rule.setdefault(group.id, []).append(rule.id)
11 if not rule.groups:
12 global_rules.append(rule.id)
13 global_domain = self.domain_create(cr, uid, global_rules)