[FIX] analytic: name_search match multi-level account names even with domain
When name_search is called with an extra domain filter (args) and a pattern (name) containing multi-level accounts, such as `A / B / C`, only the last account (`C`) has to match the domain. The intermediary parent accounts do not have to match. The domain was previously applied for each parent in the lookup. This prevented searching for multi-level accounts or copy-pasting full account names whenever a domain was present and did not match every account in the hierarchy.
This commit is contained in:
parent
9654b54d3c
commit
1576bc9891
|
@ -310,9 +310,12 @@ class account_analytic_account(osv.osv):
|
||||||
dom = []
|
dom = []
|
||||||
for name2 in name.split('/'):
|
for name2 in name.split('/'):
|
||||||
name = name2.strip()
|
name = name2.strip()
|
||||||
account_ids = self.search(cr, uid, dom + [('name', operator, name)] + args, limit=limit, context=context)
|
account_ids = self.search(cr, uid, dom + [('name', operator, name)], limit=limit, context=context)
|
||||||
if not account_ids: break
|
if not account_ids: break
|
||||||
dom = [('parent_id','in',account_ids)]
|
dom = [('parent_id','in',account_ids)]
|
||||||
|
if account_ids and args:
|
||||||
|
# final filtering according to domain (args)
|
||||||
|
account_ids = self.search(cr, uid, [('id', 'in', account_ids)] + args, limit=limit, context=context)
|
||||||
else:
|
else:
|
||||||
account_ids = self.search(cr, uid, args, limit=limit, context=context)
|
account_ids = self.search(cr, uid, args, limit=limit, context=context)
|
||||||
return self.name_get(cr, uid, account_ids, context=context)
|
return self.name_get(cr, uid, account_ids, context=context)
|
||||||
|
|
Loading…
Reference in New Issue