From 37275d597ffbecc7169ea1e1d2db6bdffab29603 Mon Sep 17 00:00:00 2001 From: Humberto Arocha Date: Mon, 5 Mar 2012 23:01:43 -0530 Subject: [PATCH] [IMP] Balance de Cuatro Columnas: -- Cuando se pide el balance solo para periodos especiales, entonces el balance proporcionaria una vista similar a: Cuenta SaldInic. Debito Credito Balance 1 Activo 0.00 200.00 150.00 50.00 11 Banco 0.00 150.00 0.00 150.00 12 CxP 0.00 50.00 0.00 50.00 13 Ant.Client. 0.00 0.00 150.00 -150.00 Observandose que la columna de los saldos iniciales esta establecida en cero. -- Cuando se pide un balance sin periodos especiales o mezclado con periodos especiales el resultado es que se tendra una columna de SaldosIniciales. Saldo de Cuentas con Movimientos, Se mostrara la cuenta siempre y cuando, la cuenta por el debito, por el credito o su saldo final sea distinto de cero. --- .../report/account_balance_4_cols.py | 32 +++++++++++++++---- 1 file changed, 26 insertions(+), 6 deletions(-) diff --git a/account_financial_report/report/account_balance_4_cols.py b/account_financial_report/report/account_balance_4_cols.py index f10f7d12..530af4d5 100644 --- a/account_financial_report/report/account_balance_4_cols.py +++ b/account_financial_report/report/account_balance_4_cols.py @@ -122,6 +122,14 @@ class account_balance(report_sxw.rml_parse): return {'periods':periods_str, 'date':dates_str} + def special_period(self, periods): + period_obj = self.pool.get('account.period') + period_brw = period_obj.browse(self.cr, self.uid, periods) + period_counter = [True for i in period_brw if not i.special] + if not period_counter: + return True + return False + def lines(self, form, ids={}, done=None, level=0): """ Returns all the data needed for the report lines @@ -192,10 +200,20 @@ class account_balance(report_sxw.rml_parse): ctx = self.context.copy() ctx['filter'] = form.get('filter','all') ctx['fiscalyear'] = fiscalyear.id - ctx['periods'] = period_obj.search(self.cr, self.uid, [('fiscalyear_id','=',fiscalyear.id),('special','=',False)]) + #~ ctx['periods'] = period_obj.search(self.cr, self.uid, [('fiscalyear_id','=',fiscalyear.id),('special','=',False)]) + + if ctx['filter'] not in ['bydate','none']: + special = self.special_period(form['periods']) + else: + special = False + if form['filter'] in ['byperiod', 'all']: - ctx['periods'] = period_obj.search(self.cr, self.uid, [('id','in',form['periods'] or ctx['periods']),('special','=',False)]) - if form['filter'] in ['bydate', 'all']: + if special: + ctx['periods'] = period_obj.search(self.cr, self.uid, [('id','in',form['periods'] or ctx['periods'])]) + else: + ctx['periods'] = period_obj.search(self.cr, self.uid, [('id','in',form['periods'] or ctx['periods']),('special','=',False)]) + + if form['filter'] in ['bydate','all','none']: ctx['date_from'] = form['date_from'] ctx['date_to'] = form['date_to'] @@ -251,8 +269,10 @@ class account_balance(report_sxw.rml_parse): period_balanceinit = {} for acc in account_obj.browse(self.cr, self.uid, [x[0] for x in account_ids], ctx): - period_balanceinit[acc['id']] = acc.balance - + if special: + period_balanceinit[acc['id']] = 0.0 + else: + period_balanceinit[acc['id']] = acc.balance # # Generate the report lines (checking each account) # @@ -302,7 +322,7 @@ class account_balance(report_sxw.rml_parse): if form['display_account'] == 'con_movimiento' and account['parent_id']: # Include accounts with movements - if abs(res['balance']) >= 0.5 * 10**-int(2): + if abs(res['debit']) >= 0.5 * 10**-int(2) or abs(res['credit']) >= 0.5 * 10**-int(2): result_acc.append(res) elif form['display_account'] == 'con_balance' and account['parent_id']: # Include accounts with balance