[TRUNK 3330] Search on mixed conditions including one2many and active=False is wrongly interpreted

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

Bug Description

sample of condition

[('category_id.code','=','PATIENT'),('active',=,False)]

Description

When server parse

1 = search all partner with category code = patient , and add active = True

2= search all partner active = False

Result = Found nothing, because active condiction not used in one2many search

My solution (not the optimal solution, no time to do it)

before line 111 (i = -1)

add

    active = False
    for exp in self.__exp:
        if exp[0] == 'active':
            active = exp

replace line 153 (right1 = table.search(cr, uid, [(fargs[0],'in', right)], context=context))

by

                if active:
                    right1 = table.search(cr, uid, [(fargs[0],'in', right),active], context=context)
                else:
                    right1 = table.search(cr, uid, [(fargs[0],'in', right)], context=context)

Note: in my example, Code is a field added in res.partner.category, so to test it, bmaybe use field name.

Related branches

Revision history for this message
Serge (sboivin) wrote :

forget

in server/bin/osv/expression.py

Class expression, method parse

Revision history for this message
Serge (sboivin) wrote :

any news ?

Changed in openobject-server:
status: New → Triaged
Revision history for this message
Olivier Dony (Odoo) (odo-openerp) wrote :

Nice catch Serge, thanks, and the proposed patch is very much appreciated.

In order to implement a proper fix, here is what I expect the code should do for your example if[('category_id.code','=','PATIENT'),('active',=,False)]:

1- first look for category_ids = [('code','=','PATIENT')] (possibly taking only active categories if there is an 'active' column in it)
2- then re-processing the domain transformed as [('category_id', 'in', category_ids), ('active','=',False)] which should work fine and consider only records with active=False that have one of these categories

PS: when proposing patches, do you have access to some command that can generate a real patch, such as "diff -u" or "bzr diff"? It can make it much easier for submitting them, and would also make them much more readable.

Thanks for reporting!

Changed in openobject-server:
assignee: nobody → OpenERP's Framework R&D (openerp-dev-framework)
importance: Undecided → Low
milestone: none → 6.0.2
status: Triaged → Confirmed
summary: - [TRUNK 3330] BUG in function parse when 2 condition and one of condion
- on one2many and other on active
+ [TRUNK 3330] Search on mixed conditions including one2many and
+ active=False is wrongly interpreted
Revision history for this message
Serge (sboivin) wrote :

i will try diff for my next report

......but, i hope i dont need to report a new bug lol

Changed in openobject-server:
status: Confirmed → In Progress
Revision history for this message
Yogesh (SerpentCS) (yogesh-serpentcs) wrote :

Hello,

Thanks for reporting and Thanks for patch.

It has been fixed in lp:~openerp-dev/openobject-server/trunk-bug-711919-ysa.
Revision No :- 3445
Revision ID : <email address hidden> and It will be merge soon
in trunk server.

Thanks,

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

Thanks for the bug report. The fix is available in trunk at revision 3735 (revision-id: <email address hidden>).

Changed in openobject-server:
milestone: 6.0.2 → none
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.