[FIX] account : fixed _search_amount() method to allow operators like <, >, =, !=, in and not in
bzr revid: ach@tinyerp.com-20100827150327-mte99e0zvpxdbb0u
This commit is contained in:
parent
64a2c35fac
commit
2da2a98449
|
@ -1051,21 +1051,25 @@ class account_move(osv.osv):
|
||||||
return result
|
return result
|
||||||
|
|
||||||
def _search_amount(self, cr, uid, obj, name, args, context):
|
def _search_amount(self, cr, uid, obj, name, args, context):
|
||||||
ids = []
|
ids = set()
|
||||||
cr.execute('select move_id,sum(debit) from account_move_line group by move_id')
|
for cond in args:
|
||||||
result = dict(cr.fetchall())
|
amount = cond[2]
|
||||||
|
if isinstance(cond[2],(list,tuple)):
|
||||||
for item in args:
|
if cond[1] in ['in','not in']:
|
||||||
if item[1] == '>=':
|
amount = tuple(cond[2])
|
||||||
res = [('id', 'in', [k for k,v in result.iteritems() if v >= item[2]])]
|
else:
|
||||||
|
continue
|
||||||
else:
|
else:
|
||||||
res = [('id', 'in', [k for k,v in result.iteritems() if v <= item[2]])]
|
if cond[1] in ['=like', 'like', 'not like', 'ilike', 'not ilike', 'in', 'not in', 'child_of']:
|
||||||
ids += res
|
continue
|
||||||
|
|
||||||
if not ids:
|
cr.execute("select move_id from account_move_line group by move_id having sum(debit) %s %%s" % (cond[1]) ,(amount,))
|
||||||
return [('id', '>', '0')]
|
res_ids = set(id[0] for id in cr.fetchall())
|
||||||
|
ids = ids and (ids & res_ids) or res_ids
|
||||||
return ids
|
if ids:
|
||||||
|
return [('id','in',tuple(ids))]
|
||||||
|
else:
|
||||||
|
return [('id', '=', '0')]
|
||||||
|
|
||||||
_columns = {
|
_columns = {
|
||||||
'name': fields.char('Number', size=64, required=True),
|
'name': fields.char('Number', size=64, required=True),
|
||||||
|
|
Loading…
Reference in New Issue