[FIX] account: custom '_where_calc' method instead of 'search'
The domain on account.account was preprocessed in search method but it had no effect on read_group. This lead to inconsistency or errors when using 'goup by' filter. Move domain processing in '_where_calc' method instead as this is used by both 'search' and 'read_group'.
This commit is contained in:
parent
717a695317
commit
a6a3db3188
|
@ -226,30 +226,37 @@ class account_account(osv.osv):
|
|||
_description = "Account"
|
||||
_parent_store = True
|
||||
|
||||
def search(self, cr, uid, args, offset=0, limit=None, order=None,
|
||||
context=None, count=False):
|
||||
if context is None:
|
||||
context = {}
|
||||
def _where_calc(self, cr, uid, domain, active_test=True, context=None):
|
||||
""" Convert domains to allow easier filtering:
|
||||
code: force case insensitive and right side matching search
|
||||
journal_id: restrict to the accounts sharing the same account.account.type
|
||||
"""
|
||||
pos = 0
|
||||
|
||||
while pos < len(args):
|
||||
|
||||
if args[pos][0] == 'code' and args[pos][1] in ('like', 'ilike') and args[pos][2]:
|
||||
args[pos] = ('code', '=like', tools.ustr(args[pos][2].replace('%', ''))+'%')
|
||||
if args[pos][0] == 'journal_id':
|
||||
if not args[pos][2]:
|
||||
del args[pos]
|
||||
while pos < len(domain):
|
||||
if domain[pos][0] == 'code' and domain[pos][1] in ('like', 'ilike') and domain[pos][2]:
|
||||
domain[pos] = ('code', '=like', tools.ustr(domain[pos][2].replace('%', '')) + '%')
|
||||
if domain[pos][0] == 'journal_id':
|
||||
if not domain[pos][2]:
|
||||
del domain[pos]
|
||||
continue
|
||||
jour = self.pool.get('account.journal').browse(cr, uid, args[pos][2], context=context)
|
||||
if (not (jour.account_control_ids or jour.type_control_ids)) or not args[pos][2]:
|
||||
args[pos] = ('type','not in',('consolidation','view'))
|
||||
jour = self.pool.get('account.journal').browse(cr, uid, domain[pos][2], context=context)
|
||||
if (not (jour.account_control_ids or jour.type_control_ids)) or not domain[pos][2]:
|
||||
domain[pos] = ('type', 'not in', ('consolidation', 'view'))
|
||||
continue
|
||||
ids3 = map(lambda x: x.id, jour.type_control_ids)
|
||||
ids1 = super(account_account, self).search(cr, uid, [('user_type', 'in', ids3)])
|
||||
ids1 += map(lambda x: x.id, jour.account_control_ids)
|
||||
args[pos] = ('id', 'in', ids1)
|
||||
domain[pos] = ('id', 'in', ids1)
|
||||
pos += 1
|
||||
|
||||
return super(account_account, self)._where_calc(cr, uid, domain, active_test, context)
|
||||
|
||||
def search(self, cr, uid, args, offset=0, limit=None, order=None,
|
||||
context=None, count=False):
|
||||
""" Check presence of key 'consolidate_children' in context to include also the Consolidated Children
|
||||
of found accounts into the result of the search
|
||||
"""
|
||||
|
||||
if context and context.has_key('consolidate_children'): #add consolidated children of accounts
|
||||
ids = super(account_account, self).search(cr, uid, args, offset, limit,
|
||||
order, context=context, count=count)
|
||||
|
|
Loading…
Reference in New Issue