[FIX] Account: Account move line => Now it will work if you have filter by dates and with initial balances
bzr revid: mra@mra-laptop-20101015061515-jct5lvb5iosc1a7p
This commit is contained in:
parent
e02663c0e5
commit
da427c55dc
|
@ -32,11 +32,13 @@ class account_move_line(osv.osv):
|
|||
_name = "account.move.line"
|
||||
_description = "Journal Items"
|
||||
|
||||
def _query_get(self, cr, uid, obj='l', context={}):
|
||||
def _query_get(self, cr, uid, obj='l', context=None):
|
||||
fiscalyear_obj = self.pool.get('account.fiscalyear')
|
||||
fiscalperiod_obj = self.pool.get('account.period')
|
||||
fiscalyear_ids = []
|
||||
fiscalperiod_ids = []
|
||||
if context is None:
|
||||
context = {}
|
||||
initial_bal = context.get('initial_bal', False)
|
||||
company_clause = ""
|
||||
if context.get('company_id', False):
|
||||
|
@ -58,7 +60,7 @@ class account_move_line(osv.osv):
|
|||
|
||||
if context.get('date_from', False) and context.get('date_to', False):
|
||||
if initial_bal:
|
||||
where_move_lines_by_date = " AND " +obj+".move_id in ( select id from account_move where date < '"+context['date_from']+"')"
|
||||
where_move_lines_by_date = " OR " +obj+".move_id in ( select id from account_move where date < '"+context['date_from']+"')"
|
||||
else:
|
||||
where_move_lines_by_date = " AND " +obj+".move_id in ( select id from account_move where date >= '" +context['date_from']+"' AND date <= '"+context['date_to']+"')"
|
||||
|
||||
|
@ -88,7 +90,7 @@ class account_move_line(osv.osv):
|
|||
ids = ','.join([str(x) for x in context['periods']])
|
||||
query = obj+".state<>'draft' AND "+obj+".period_id in (SELECT id from account_period WHERE fiscalyear_id in (%s) AND id in (%s)) %s %s" % (fiscalyear_clause, ids, where_move_state, where_move_lines_by_date)
|
||||
else:
|
||||
query = obj+".state<>'draft' AND "+obj+".period_id in (SELECT id from account_period WHERE fiscalyear_id in (%s) %s %s)" % (fiscalyear_clause,where_move_state,where_move_lines_by_date)
|
||||
query = obj+".state<>'draft' AND "+obj+".period_id in (SELECT id from account_period WHERE fiscalyear_id in (%s) %s %s)" % (fiscalyear_clause, where_move_state, where_move_lines_by_date)
|
||||
|
||||
if context.get('journal_ids', False):
|
||||
query += ' AND '+obj+'.journal_id in (%s)' % ','.join(map(str, context['journal_ids']))
|
||||
|
|
Loading…
Reference in New Issue