ORM searching for calculated fields replaces query with 'True' with no warning

Bug #1037497 reported by Colin Newell
8
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Odoo Server (MOVED TO GITHUB)
Confirmed
Medium
OpenERP's Framework R&D

Bug Description

If I make an or query like this with partner_ref as part of the search the ORM silently replaces the partner_ref part with an expression that evaluates to true. Since this is in an OR expression, this makes that whole part of the query redundant since anything OR TRUE is TRUE.

At the very least it would be useful if there was some debug output saying what the ORM is doing.

2012-08-16 10:49:00,507 12436 DEBUG ? openerp.netsvc.rpc.request: object.execute('openerp',
2012-08-16 10:49:00,508 12436 DEBUG ? openerp.netsvc.rpc.request: 1,
2012-08-16 10:49:00,508 12436 DEBUG ? openerp.netsvc.rpc.request: '*',
2012-08-16 10:49:00,508 12436 DEBUG ? openerp.netsvc.rpc.request: 'product.product',
2012-08-16 10:49:00,508 12436 DEBUG ? openerp.netsvc.rpc.request: 'search',
2012-08-16 10:49:00,508 12436 DEBUG ? openerp.netsvc.rpc.request: ['|',
2012-08-16 10:49:00,508 12436 DEBUG ? openerp.netsvc.rpc.request: '|',
2012-08-16 10:49:00,508 12436 DEBUG ? openerp.netsvc.rpc.request: '|',
2012-08-16 10:49:00,508 12436 DEBUG ? openerp.netsvc.rpc.request: '|',
2012-08-16 10:49:00,508 12436 DEBUG ? openerp.netsvc.rpc.request: ['description', 'ilike', '%description%'],
2012-08-16 10:49:00,509 12436 DEBUG ? openerp.netsvc.rpc.request: ['description_sale', 'ilike', '%description_sale%'],
2012-08-16 10:49:00,509 12436 DEBUG ? openerp.netsvc.rpc.request: ['name', 'ilike', '%name%'],
2012-08-16 10:49:00,509 12436 DEBUG ? openerp.netsvc.rpc.request: ['default_code', 'ilike', '%default_code%'],
2012-08-16 10:49:00,509 12436 DEBUG ? openerp.netsvc.rpc.request: ['partner_ref', 'ilike', '%partner_ref%'],
2012-08-16 10:49:00,509 12436 DEBUG ? openerp.netsvc.rpc.request: ['active', '=', 1]])

The code that does the replacement is in osv/expression.py and the code looks something like this,

                    # the function field doesn't provide a search function and doesn't store
                    # values in the database, so we must ignore it : we generate a dummy leaf
                    self.__exp[i] = TRUE_LEAF

It's actually done in a couple of places and I'm not entirely sure which one I'm hitting.

Amit Parik (amit-parik)
affects: openobject-addons → openobject-server
Changed in openobject-server:
assignee: nobody → OpenERP's Framework R&D (openerp-dev-framework)
importance: Undecided → Medium
status: New → Confirmed
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.