[FIX] account: filter out special periods
When computing the balance, debit and/or credit, the opening period must be filtered out. Otherwise, the invoices which are still opened at the time of the period closing will be counted twice. opw-670584
This commit is contained in:
parent
f66fcf97b2
commit
7b7f3fa76a
|
@ -314,7 +314,7 @@ class account_account(osv.osv):
|
|||
res = {}
|
||||
null_result = dict((fn, 0.0) for fn in field_names)
|
||||
if children_and_consolidated:
|
||||
aml_query = self.pool.get('account.move.line')._query_get(cr, uid, context=context)
|
||||
aml_query = self.pool.get('account.move.line')._query_get(cr, uid, context=dict(context or {}, periods_special=False))
|
||||
|
||||
wheres = [""]
|
||||
if query.strip():
|
||||
|
|
|
@ -83,19 +83,23 @@ class account_move_line(osv.osv):
|
|||
context['periods'] = fiscalperiod_obj.build_ctx_periods(cr, uid, first_period, context['period_from'])
|
||||
else:
|
||||
context['periods'] = fiscalperiod_obj.build_ctx_periods(cr, uid, context['period_from'], context['period_to'])
|
||||
if 'periods_special' in context:
|
||||
periods_special = ' AND special = %s ' % bool(context.get('periods_special'))
|
||||
else:
|
||||
periods_special = ''
|
||||
if context.get('periods'):
|
||||
query_params['period_ids'] = tuple(context['periods'])
|
||||
if initial_bal:
|
||||
query = obj+".state <> 'draft' AND "+obj+".period_id IN (SELECT id FROM account_period WHERE fiscalyear_id IN %(fiscalyear_ids)s)" + 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 %(fiscalyear_ids)s" + periods_special + ")" + where_move_state + where_move_lines_by_date
|
||||
period_ids = fiscalperiod_obj.search(cr, uid, [('id', 'in', context['periods'])], order='date_start', limit=1)
|
||||
if period_ids and period_ids[0]:
|
||||
first_period = fiscalperiod_obj.browse(cr, uid, period_ids[0], context=context)
|
||||
query_params['date_start'] = first_period.date_start
|
||||
query = obj+".state <> 'draft' AND "+obj+".period_id IN (SELECT id FROM account_period WHERE fiscalyear_id IN %(fiscalyear_ids)s AND date_start <= %(date_start)s AND id NOT IN %(period_ids)s)" + 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 %(fiscalyear_ids)s AND date_start <= %(date_start)s AND id NOT IN %(period_ids)s" + periods_special + ")" + 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 %(fiscalyear_ids)s AND id IN %(period_ids)s)" + 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 %(fiscalyear_ids)s AND id IN %(period_ids)s" + periods_special + ")" + 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 %(fiscalyear_ids)s)" + 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 %(fiscalyear_ids)s" + periods_special + ")" + where_move_state + where_move_lines_by_date
|
||||
|
||||
if initial_bal and not context.get('periods') and not where_move_lines_by_date:
|
||||
#we didn't pass any filter in the context, and the initial balance can't be computed using only the fiscalyear otherwise entries will be summed twice
|
||||
|
|
Loading…
Reference in New Issue