Merge lp:~therp-nl/ocb-addons/6.1_fix_analytic_account_name_search into lp:ocb-addons/6.1

Proposed by Holger Brunn (Therp)
Status: Merged
Merged at revision: 6766
Proposed branch: lp:~therp-nl/ocb-addons/6.1_fix_analytic_account_name_search
Merge into: lp:ocb-addons/6.1
Diff against target: 31 lines (+9/-12)
1 file modified
analytic/analytic.py (+9/-12)
To merge this branch: bzr merge lp:~therp-nl/ocb-addons/6.1_fix_analytic_account_name_search
Reviewer Review Type Date Requested Status
Guewen Baconnier @ Camptocamp code review Approve
Maxime Chambreuil (http://www.savoirfairelinux.com) code review, no test Approve
Stefan Rijnhart (Opener) Approve
Review via email: mp+173737@code.launchpad.net

Commit message

[IMP] backported lp:openobject-addons rev 8463,8464

Description of the change

In 6.1, there can be too few results from autocomplete in many2one fields to account.analytic.account if there is a domain involved. This is caused by the fact that we have multiple searches with the limit of 8 in effect of which only the last applies the domain. So if the first eight results from the previous search don't match, bad luck for you.

Given that there is some other stuff wrong with this part of the function too, I backported what 7.0 does:
http://bazaar.launchpad.net/~openerp/openobject-addons/trunk/revision/8464

To post a comment you must log in.
Revision history for this message
Stefan Rijnhart (Opener) (stefan-opener) wrote :

Thanks!

You seem to have missed the line

    name = name2.strip()

Otherwise fine.

review: Needs Fixing
Revision history for this message
Holger Brunn (Therp) (hbrunn) wrote :

Thank for point that out! This line is missing on purpose. But I tried to be smarter than I am, now it's okay.

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

Thanks!

review: Approve
Revision history for this message
Maxime Chambreuil (http://www.savoirfairelinux.com) (max3903) :
review: Approve (code review, no test)
Revision history for this message
Guewen Baconnier @ Camptocamp (gbaconnier-c2c) wrote :

LGTM

review: Approve (code review)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'analytic/analytic.py'
2--- analytic/analytic.py 2012-02-16 18:01:11 +0000
3+++ analytic/analytic.py 2013-07-09 14:55:30 +0000
4@@ -263,18 +263,15 @@
5 if name:
6 account = self.search(cr, uid, [('code', '=', name)] + args, limit=limit, context=context)
7 if not account:
8- names=map(lambda i : i.strip(),name.split('/'))
9- for i in range(len(names)):
10- dom=[('name', operator, names[i])]
11- if i>0:
12- dom+=[('id','child_of',account)]
13- account = self.search(cr, uid, dom, limit=limit, context=context)
14- newacc = account
15- while newacc:
16- newacc = self.search(cr, uid, [('parent_id', 'in', newacc)], limit=limit, context=context)
17- account += newacc
18- if args:
19- account = self.search(cr, uid, [('id', 'in', account)] + args, limit=limit, context=context)
20+ dom = []
21+ for name2 in map(lambda i : i.strip(),name.split('/')):
22+ account = self.search(
23+ cr, uid,
24+ dom + [('name', 'ilike', name2)] + args,
25+ limit=limit, context=context)
26+ if not account:
27+ break
28+ dom = [('parent_id','in',account)]
29 else:
30 account = self.search(cr, uid, args, limit=limit, context=context)
31 return self.name_get(cr, uid, account, context=context)

Subscribers

People subscribed via source and target branches