[FIX] account: wrong initial balance in GL
When the General Ledger is printed, the initial balance is zero if the filtering is done by period. It appears that in this case, the method `_query_get` selects all the periods before the selected period range thanks to: `build_ctx_periods(cr, uid, first_period, context['period_from'])` On the other hand, `_query_get` builds the query as: `date_start <= %(date_start)s AND id NOT IN %(period_ids)s` That doesn't make sense since we first choose the periods before the selected period range, then we exclude them. What the method `_query_get` is doing seems wrong, but since this method is used in many reports, it is safer to only fix the GL report directly. Another solution could be https://gist.github.com/nim-odoo/453176d9ae820615e69f9a809a3780cc opw-681601
This commit is contained in:
parent
dbf44a9680
commit
6742d1fafe
|
@ -45,7 +45,6 @@ class general_ledger(report_sxw.rml_parse, common_report_header):
|
|||
self.init_balance = data['form'].get('initial_balance', True)
|
||||
if self.init_balance:
|
||||
ctx2.update({'initial_bal': True})
|
||||
self.init_query = obj_move._query_get(self.cr, self.uid, obj='l', context=ctx2)
|
||||
self.display_account = data['form']['display_account']
|
||||
self.target_move = data['form'].get('target_move', 'all')
|
||||
ctx = self.context.copy()
|
||||
|
@ -54,11 +53,14 @@ class general_ledger(report_sxw.rml_parse, common_report_header):
|
|||
period_from_id = data['form']['period_from']
|
||||
period_to_id = data['form']['period_to']
|
||||
ctx['periods'] = self.pool["account.period"].build_ctx_periods(self.cr, self.uid, period_from_id, period_to_id)
|
||||
# Do not let "_query_get" calculate the periods itself
|
||||
ctx2.update({'periods': ctx['periods']})
|
||||
elif data['form']['filter'] == 'filter_date':
|
||||
ctx['date_from'] = data['form']['date_from']
|
||||
ctx['date_to'] = data['form']['date_to']
|
||||
ctx['state'] = data['form']['target_move']
|
||||
self.context.update(ctx)
|
||||
self.init_query = obj_move._query_get(self.cr, self.uid, obj='l', context=ctx2)
|
||||
if (data['model'] == 'ir.ui.menu'):
|
||||
new_ids = [data['form']['chart_account_id']]
|
||||
objects = self.pool.get('account.account').browse(self.cr, self.uid, new_ids)
|
||||
|
|
Loading…
Reference in New Issue