Record rules with domain blank or [] result in application error

Bug #719406 reported by LMK
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Odoo Server (MOVED TO GITHUB)
Fix Released
Medium
OpenERP's Framework R&D

Bug Description

1. In v6.0.1, create any record rule with empty domain [].
2. Log in with user other than admin and pull up any view that invokes above rule, following application error will be reported:
  File "C:\Program Files\OpenERP 6.0\Server\addons\base\ir\ir_rule.py", line 141, in domain_get
  File "osv\orm.pyo", line 3823, in _where_calc
  File "osv\expression.pyo", line 499, in to_sql
IndexError: pop from empty list

Related branches

Revision history for this message
Amit Parik (amit-parik) wrote :

Hello,

I have tested your scenario with latest trunk. But all are working fine.

I have created a one record rule for the particular group with domain="[ ] " and login with the another user which have assign this group and this is working fine.

So would you please provide the more information or proper example to reproduce this error.

I have attached a video for your reference, So please check it and notify me where you faced the problem.

Thanks.

Revision history for this message
Amit Parik (amit-parik) wrote :
Changed in openobject-server:
status: New → Incomplete
Changed in openobject-server:
status: Incomplete → Confirmed
importance: Undecided → Medium
milestone: none → 6.0.2
assignee: nobody → Jay Vora (OpenERP) (jvo-openerp)
summary: - Record rules with domain [] result in application error
+ Record rules with domain blank or [] result in application error
Revision history for this message
Jay Vora (Serpent Consulting Services) (jayvora) wrote :

Hello,

Forgot to mention that the bug can be produced when the record rule is applied to a group in standalone manner(only one record rule to a group and user has no other group relevant to the model).

Thanks.

Changed in openobject-server:
assignee: Jay Vora (OpenERP) (jvo-openerp) → OpenERP's Framework R&D (openerp-dev-framework)
Revision history for this message
Vo Minh Thu (thu) wrote :

Hi Jay,

I tried to reproduce the bug (by adding a rule to the group Employee on res.partner and opening Sales/Address book/Customers with the demo user). I got a different error (see below) on the empty case, but no problem on the [ ] case. Can you give a particular example where you got that behavior? I have a fix for my case at https://code.launchpad.net/~openerp-dev/openobject-server/6.0-bug-719406-empty-ir-rule-vmt and will add fixes for your cases if I can reproduce them.

  File "/home/openerp/repos/server/6.0-bug-719406-empty-record-rule/bin/osv/fields.py", line 793, in get
    res = self._fnct(obj, cr, user, ids, name, self._arg, context)
  File "/home/openerp/repos/server/6.0-bug-719406-empty-record-rule/bin/addons/base/ir/ir_rule.py", line 40, in _domain_force_get
    res[rule.id] = eval(rule.domain_force, eval_user_data)
  File "/home/openerp/repos/server/6.0-bug-719406-empty-record-rule/bin/tools/safe_eval.py", line 240, in safe_eval
    if '__subclasses__' in expr:

Revision history for this message
Jay Vora (Serpent Consulting Services) (jayvora) wrote :

Hello Vo Minh Thu,

Thanks for the merge proposal and for the fix.

Well, the problem is fixed partially and your merge tends to fix the problem only when the domain is '' (Blank).

There is a case where you can face the problem.
Go to the particular record rule,set the domain as [],and make sure your user is in the group given. If you have the similar configuration,you won't face any problem there is only one group.

When there are more than one groups given to the record rule, system appends ['|'] to the domain ,but as the domain is [],no more operands are appended.

So, the result of a domain is [' | ' ] * (no_of_groups -1). (e.g. for 3 groups to a rule ,domain will be ['|','|']), and so there is a pop error.

Hope this is clear.

Thanks.

Changed in openobject-server:
status: Confirmed → In Progress
Changed in openobject-server:
status: In Progress → Fix Committed
Revision history for this message
Vo Minh Thu (thu) wrote :

The fix has been merged in trunk at revision 3361. Thanks a lot for reporting the bug!

Changed in openobject-server:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.