From 21a61c6b3877908a79bdfbae2032afe4dc5d1a44 Mon Sep 17 00:00:00 2001 From: Humberto Arocha Date: Thu, 21 Jun 2012 01:40:14 -0530 Subject: [PATCH 1/5] [ADD] Added currency_id field, so that now it is possible to get accounting reports in another currency other than the company currency. [IMP] Given that the new field was added When no currency is selected the company currency is the default, is a different currency all the values will be expressed into that new currency. This behavior is now only available for the four (4) columns report, Will it be necessary to take into account which date rate, the actual or another date for that exchange. --- .../report/account_balance_4_cols.py | 35 ++++++++++++++++--- .../report/balance_full_4_cols.rml | 2 +- .../wizard/account_report_wizard.xml | 5 ++- .../wizard/wizard_account_balance_4_report.py | 1 + 4 files changed, 36 insertions(+), 7 deletions(-) diff --git a/account_financial_report/report/account_balance_4_cols.py b/account_financial_report/report/account_balance_4_cols.py index f36087d1..781d6fc8 100644 --- a/account_financial_report/report/account_balance_4_cols.py +++ b/account_financial_report/report/account_balance_4_cols.py @@ -55,6 +55,7 @@ class account_balance(report_sxw.rml_parse): 'get_periods_and_date_text': self.get_periods_and_date_text, 'get_informe_text': self.get_informe_text, 'get_month':self.get_month, + 'exchange_name':self.exchange_name, }) self.context = context @@ -129,13 +130,37 @@ class account_balance(report_sxw.rml_parse): if not period_counter: return True return False - + + def exchange_name(self, form): + self.from_currency_id = self.get_company_currency(form['company_id'] and form['company_id'][0]) + if not form['currency_id']: + self.to_currency_id = self.from_currency_id + else: + self.to_currency_id = form['currency_id'] and form['currency_id'][0] + return self.pool.get('res.currency').browse(self.cr, self.uid, self.to_currency_id).name + + def exchange(self, from_amount): + if self.from_currency_id == self.to_currency_id: + return from_amount + curr_obj = self.pool.get('res.currency') + return curr_obj.compute(self.cr, self.uid, self.from_currency_id, self.to_currency_id, from_amount) + + def get_company_currency(self, company_id): + rc_obj = self.pool.get('res.company') + return rc_obj.browse(self.cr, self.uid, company_id).currency_id.id + def lines(self, form, ids={}, done=None, level=0): """ Returns all the data needed for the report lines (account info plus debit/credit/balance in the selected period and the full year) """ + self.from_currency_id = self.get_company_currency(form['company_id'] and form['company_id'][0]) + if not form['currency_id']: + self.to_currency_id = self.from_currency_id + else: + self.to_currency_id = form['currency_id'] and form['currency_id'][0] + tot_bin = 0.0 tot_deb = 0.0 tot_crd = 0.0 @@ -300,10 +325,10 @@ class account_balance(report_sxw.rml_parse): 'code': account['code'], 'name': (account['total'] and not account['label']) and 'TOTAL %s'%(account['name'].upper()) or account['name'], 'level': account['level'], - 'balanceinit': period_balanceinit[account_id], - 'debit': account['debit'], - 'credit': account['credit'], - 'balance': period_balanceinit[account_id]+account['debit']-account['credit'], + 'balanceinit': self.exchange(period_balanceinit[account_id]), + 'debit': self.exchange(account['debit']), + 'credit': self.exchange(account['credit']), + 'balance': self.exchange(period_balanceinit[account_id]+account['debit']-account['credit']), 'parent_id': account['parent_id'], 'bal_type': '', 'label': account['label'], diff --git a/account_financial_report/report/balance_full_4_cols.rml b/account_financial_report/report/balance_full_4_cols.rml index 9af85ebe..1004de65 100644 --- a/account_financial_report/report/balance_full_4_cols.rml +++ b/account_financial_report/report/balance_full_4_cols.rml @@ -26,7 +26,7 @@ - [[data['form'] and (' (Expresado en %s)'%( company.currency_id.name)) or '']] + [[data['form'] and (' (Expresado en %s)'%( exchange_name(data['form']))) or '']] diff --git a/account_financial_report/wizard/account_report_wizard.xml b/account_financial_report/wizard/account_report_wizard.xml index 47287abb..ba5ae4ec 100644 --- a/account_financial_report/wizard/account_report_wizard.xml +++ b/account_financial_report/wizard/account_report_wizard.xml @@ -8,8 +8,11 @@ form
- + + + + diff --git a/account_financial_report/wizard/wizard_account_balance_4_report.py b/account_financial_report/wizard/wizard_account_balance_4_report.py index d53d4730..a7a75de4 100644 --- a/account_financial_report/wizard/wizard_account_balance_4_report.py +++ b/account_financial_report/wizard/wizard_account_balance_4_report.py @@ -48,6 +48,7 @@ class wizard_report(osv.osv_memory): 'lab_str': fields.char('Description', size= 128), 'inf_type': fields.selection([('bgen','Balance General'),('bcom','Balance Comprobacion'),('edogp','Estado Ganancias y Perdidas'),('bml','Libro Mayor Legal')],'Tipo Informe',required=True), #~ 'type_report': fields.selection([('un_col','Una Columna'),('dos_col','Dos Columnas'),('cuatro_col','Cuatro Columnas')],'Tipo Informe',required=True), + 'currency_id': fields.many2one('res.currency', 'Secondary Currency', help="Forces all values for this report to be expressed in this secondary currency."), } _defaults = { From 17d6edd9f099e7aaf4bb60a9d59a55640ab0e7a5 Mon Sep 17 00:00:00 2001 From: Humberto Arocha Date: Thu, 21 Jun 2012 18:05:53 -0530 Subject: [PATCH 2/5] [ADD] Added Fields For Currency in the one and two columns reports, --- .../report/account_balance.py | 30 ++++++++++++++- .../report/account_balance_2_cols.py | 38 +++++++++++++++++-- .../report/balance_full.rml | 2 +- .../report/balance_full_2_cols.rml | 2 +- .../wizard/account_report_wizard.xml | 11 +++++- .../wizard/wizard_account_balance_2_report.py | 1 + .../wizard/wizard_account_balance_report.py | 1 + 7 files changed, 75 insertions(+), 10 deletions(-) diff --git a/account_financial_report/report/account_balance.py b/account_financial_report/report/account_balance.py index 94d1d1b3..82fa5e65 100644 --- a/account_financial_report/report/account_balance.py +++ b/account_financial_report/report/account_balance.py @@ -55,6 +55,7 @@ class account_balance(report_sxw.rml_parse): 'get_periods_and_date_text': self.get_periods_and_date_text, 'get_informe_text': self.get_informe_text, 'get_month':self.get_month, + 'exchange_name':self.exchange_name, }) self.context = context @@ -121,6 +122,24 @@ class account_balance(report_sxw.rml_parse): return {'periods':periods_str, 'date':dates_str} + def exchange_name(self, form): + self.from_currency_id = self.get_company_currency(form['company_id'] and form['company_id'][0]) + if not form['currency_id']: + self.to_currency_id = self.from_currency_id + else: + self.to_currency_id = form['currency_id'] and form['currency_id'][0] + return self.pool.get('res.currency').browse(self.cr, self.uid, self.to_currency_id).name + + def exchange(self, from_amount): + if self.from_currency_id == self.to_currency_id: + return from_amount + curr_obj = self.pool.get('res.currency') + return curr_obj.compute(self.cr, self.uid, self.from_currency_id, self.to_currency_id, from_amount) + + def get_company_currency(self, company_id): + rc_obj = self.pool.get('res.company') + return rc_obj.browse(self.cr, self.uid, company_id).currency_id.id + def lines(self, form, ids={}, done=None, level=0): """ @@ -128,6 +147,13 @@ class account_balance(report_sxw.rml_parse): (account info plus debit/credit/balance in the selected period and the full year) """ + + self.from_currency_id = self.get_company_currency(form['company_id'] and form['company_id'][0]) + if not form['currency_id']: + self.to_currency_id = self.from_currency_id + else: + self.to_currency_id = form['currency_id'] and form['currency_id'][0] + tot_eje = 0.0 if not ids: ids = self.ids @@ -265,7 +291,7 @@ class account_balance(report_sxw.rml_parse): 'code': account['code'], 'name': (account['total'] and not account['label']) and 'TOTAL %s'%(account['name'].upper()) or account['name'], 'level': account['level'], - 'balance': account['balance'], + 'balance': self.exchange(account['balance']), 'parent_id': account['parent_id'], 'bal_type': '', 'label': account['label'], @@ -302,7 +328,7 @@ class account_balance(report_sxw.rml_parse): res2 = { 'type' : 'view', 'name': 'TOTAL %s'%(str_label), - 'balance': tot_eje, + 'balance': self.exchange(tot_eje), 'label': False, 'total': True, } diff --git a/account_financial_report/report/account_balance_2_cols.py b/account_financial_report/report/account_balance_2_cols.py index 2c140904..6f00642f 100644 --- a/account_financial_report/report/account_balance_2_cols.py +++ b/account_financial_report/report/account_balance_2_cols.py @@ -55,6 +55,7 @@ class account_balance(report_sxw.rml_parse): 'get_periods_and_date_text': self.get_periods_and_date_text, 'get_informe_text': self.get_informe_text, 'get_month':self.get_month, + 'exchange_name':self.exchange_name, }) self.context = context @@ -122,12 +123,41 @@ class account_balance(report_sxw.rml_parse): return {'periods':periods_str, 'date':dates_str} + + def exchange_name(self, form): + self.from_currency_id = self.get_company_currency(form['company_id'] and form['company_id'][0]) + if not form['currency_id']: + self.to_currency_id = self.from_currency_id + else: + self.to_currency_id = form['currency_id'] and form['currency_id'][0] + return self.pool.get('res.currency').browse(self.cr, self.uid, self.to_currency_id).name + + def exchange(self, from_amount): + if self.from_currency_id == self.to_currency_id: + return from_amount + curr_obj = self.pool.get('res.currency') + return curr_obj.compute(self.cr, self.uid, self.from_currency_id, self.to_currency_id, from_amount) + + def get_company_currency(self, company_id): + rc_obj = self.pool.get('res.company') + return rc_obj.browse(self.cr, self.uid, company_id).currency_id.id + + + def lines(self, form, ids={}, done=None, level=0): """ Returns all the data needed for the report lines (account info plus debit/credit/balance in the selected period and the full year) """ + + + self.from_currency_id = self.get_company_currency(form['company_id'] and form['company_id'][0]) + if not form['currency_id']: + self.to_currency_id = self.from_currency_id + else: + self.to_currency_id = form['currency_id'] and form['currency_id'][0] + tot_bin = 0.0 tot_deb = 0.0 tot_crd = 0.0 @@ -280,10 +310,10 @@ class account_balance(report_sxw.rml_parse): 'code': account['code'], 'name': (account['total'] and not account['label']) and 'TOTAL %s'%(account['name'].upper()) or account['name'], 'level': account['level'], - 'balanceinit': period_balanceinit[account_id], - 'debit': account['debit'], - 'credit': account['credit'], - 'balance': period_balanceinit[account_id]+account['debit']-account['credit'], + 'balanceinit': self.exchange(period_balanceinit[account_id]), + 'debit': self.exchange(account['debit']), + 'credit': self.exchange(account['credit']), + 'balance': self.exchange(period_balanceinit[account_id]+account['debit']-account['credit']), 'parent_id': account['parent_id'], 'bal_type': '', 'label': account['label'], diff --git a/account_financial_report/report/balance_full.rml b/account_financial_report/report/balance_full.rml index d75a846e..83513f0f 100644 --- a/account_financial_report/report/balance_full.rml +++ b/account_financial_report/report/balance_full.rml @@ -16,7 +16,7 @@ - [[ get_informe_text(data['form']) ]][[data['form'] and (' (Expresado en %s)'%( company.currency_id.name)) or '']] + [[data['form'] and (' (Expresado en %s)'%( exchange_name(data['form']))) or '']] diff --git a/account_financial_report/report/balance_full_2_cols.rml b/account_financial_report/report/balance_full_2_cols.rml index 55bc336d..5e3f3adb 100644 --- a/account_financial_report/report/balance_full_2_cols.rml +++ b/account_financial_report/report/balance_full_2_cols.rml @@ -20,7 +20,7 @@ - [[data['form'] and (' (Expresado en %s)'%( company.currency_id.name)) or '']] + [[data['form'] and (' (Expresado en %s)'%( exchange_name(data['form']))) or '']] diff --git a/account_financial_report/wizard/account_report_wizard.xml b/account_financial_report/wizard/account_report_wizard.xml index ba5ae4ec..2b27d638 100644 --- a/account_financial_report/wizard/account_report_wizard.xml +++ b/account_financial_report/wizard/account_report_wizard.xml @@ -78,8 +78,11 @@ form - + + + + @@ -141,8 +144,12 @@ form - + + + + + diff --git a/account_financial_report/wizard/wizard_account_balance_2_report.py b/account_financial_report/wizard/wizard_account_balance_2_report.py index 439463f3..2b809de4 100644 --- a/account_financial_report/wizard/wizard_account_balance_2_report.py +++ b/account_financial_report/wizard/wizard_account_balance_2_report.py @@ -48,6 +48,7 @@ class wizard_account_balance_gene_2(osv.osv_memory): 'lab_str': fields.char('Description', size= 128), 'inf_type': fields.selection([('bgen','Balance General'),('bcom','Balance Comprobacion'),('edogp','Estado Ganancias y Perdidas'),('bdl','Diario Legal')],'Tipo Informe',required=True), #~ 'type_report': fields.selection([('un_col','Una Columna'),('dos_col','Dos Columnas'),('cuatro_col','Cuatro Columnas')],'Tipo Informe',required=True), + 'currency_id': fields.many2one('res.currency', 'Secondary Currency', help="Forces all values for this report to be expressed in this secondary currency."), } _defaults = { diff --git a/account_financial_report/wizard/wizard_account_balance_report.py b/account_financial_report/wizard/wizard_account_balance_report.py index 8b3ecfd4..9088adc5 100644 --- a/account_financial_report/wizard/wizard_account_balance_report.py +++ b/account_financial_report/wizard/wizard_account_balance_report.py @@ -48,6 +48,7 @@ class wizard_account_balance_gene(osv.osv_memory): 'lab_str': fields.char('Description', size= 128), 'inf_type': fields.selection([('bgen','Balance General'),('bcom','Balance Comprobacion'),('edogp','Estado Ganancias y Perdidas')],'Tipo Informe',required=True), #~ 'type_report': fields.selection([('un_col','Una Columna'),('dos_col','Dos Columnas'),('cuatro_col','Cuatro Columnas')],'Tipo Informe',required=True), + 'currency_id': fields.many2one('res.currency', 'Secondary Currency', help="Forces all values for this report to be expressed in this secondary currency."), } _defaults = { From 6f18c9e8d921bf0e367cf1ce213bed5c4d5b49fc Mon Sep 17 00:00:00 2001 From: Humberto Arocha Date: Thu, 21 Jun 2012 22:04:02 -0530 Subject: [PATCH 3/5] [FIX] Fixed bug that avoided to generate a report in v6.1 of openerp client --- .../report/account_balance.py | 23 ++++++------------- .../report/account_balance_2_cols.py | 23 +++++-------------- .../report/account_balance_4_cols.py | 22 +++++------------- 3 files changed, 19 insertions(+), 49 deletions(-) diff --git a/account_financial_report/report/account_balance.py b/account_financial_report/report/account_balance.py index 82fa5e65..9bab471e 100644 --- a/account_financial_report/report/account_balance.py +++ b/account_financial_report/report/account_balance.py @@ -141,7 +141,7 @@ class account_balance(report_sxw.rml_parse): return rc_obj.browse(self.cr, self.uid, company_id).currency_id.id - def lines(self, form, ids={}, done=None, level=0): + def lines(self, form, level=0): """ Returns all the data needed for the report lines (account info plus debit/credit/balance in the selected period @@ -155,12 +155,7 @@ class account_balance(report_sxw.rml_parse): self.to_currency_id = form['currency_id'] and form['currency_id'][0] tot_eje = 0.0 - if not ids: - ids = self.ids - if not ids: - return [] - if not done: - done = {} + if form.has_key('account_list') and form['account_list']: account_ids = form['account_list'] del form['account_list'] @@ -172,11 +167,12 @@ class account_balance(report_sxw.rml_parse): fiscalyear_obj = self.pool.get('account.fiscalyear') # Get the fiscal year - fiscalyear = None if form.get('fiscalyear'): - fiscalyear = fiscalyear_obj.browse(self.cr, self.uid, form['fiscalyear']) - else: - fiscalyear = fiscalyear_obj.browse(self.cr, self.uid, fiscalyear_obj.find(self.cr, self.uid)) + if type(form.get('fiscalyear')) in (list,tuple): + fiscalyear = form['fiscalyear'] and form['fiscalyear'][0] + elif type(form.get('fiscalyear')) in (int,): + fiscalyear = form['fiscalyear'] + fiscalyear = fiscalyear_obj.browse(self.cr, self.uid, fiscalyear) # # Get the accounts @@ -267,11 +263,6 @@ class account_balance(report_sxw.rml_parse): for account in accounts: account_id = account['id'] - if account_id in done: - pass - - done[account_id] = 1 - # # Calculate the account level # diff --git a/account_financial_report/report/account_balance_2_cols.py b/account_financial_report/report/account_balance_2_cols.py index 6f00642f..5fd17377 100644 --- a/account_financial_report/report/account_balance_2_cols.py +++ b/account_financial_report/report/account_balance_2_cols.py @@ -144,7 +144,7 @@ class account_balance(report_sxw.rml_parse): - def lines(self, form, ids={}, done=None, level=0): + def lines(self, form, level=0): """ Returns all the data needed for the report lines (account info plus debit/credit/balance in the selected period @@ -162,12 +162,6 @@ class account_balance(report_sxw.rml_parse): tot_deb = 0.0 tot_crd = 0.0 tot_eje = 0.0 - if not ids: - ids = self.ids - if not ids: - return [] - if not done: - done = {} if form.has_key('account_list') and form['account_list']: account_ids = form['account_list'] @@ -179,12 +173,12 @@ class account_balance(report_sxw.rml_parse): period_obj = self.pool.get('account.period') fiscalyear_obj = self.pool.get('account.fiscalyear') - fiscalyear = None if form.get('fiscalyear'): - fiscalyear = fiscalyear_obj.browse(self.cr, self.uid, form['fiscalyear']) - else: - fiscalyear = fiscalyear_obj.browse(self.cr, self.uid, fiscalyear_obj.find(self.cr, self.uid)) - + if type(form.get('fiscalyear')) in (list,tuple): + fiscalyear = form['fiscalyear'] and form['fiscalyear'][0] + elif type(form.get('fiscalyear')) in (int,): + fiscalyear = form['fiscalyear'] + fiscalyear = fiscalyear_obj.browse(self.cr, self.uid, fiscalyear) # # Get the accounts # @@ -290,11 +284,6 @@ class account_balance(report_sxw.rml_parse): for account in accounts: account_id = account['id'] - if account_id in done: - pass - - done[account_id] = 1 - accounts_levels[account_id] = account['level'] # diff --git a/account_financial_report/report/account_balance_4_cols.py b/account_financial_report/report/account_balance_4_cols.py index 781d6fc8..b131d9c2 100644 --- a/account_financial_report/report/account_balance_4_cols.py +++ b/account_financial_report/report/account_balance_4_cols.py @@ -149,7 +149,7 @@ class account_balance(report_sxw.rml_parse): rc_obj = self.pool.get('res.company') return rc_obj.browse(self.cr, self.uid, company_id).currency_id.id - def lines(self, form, ids={}, done=None, level=0): + def lines(self, form, level=0): """ Returns all the data needed for the report lines (account info plus debit/credit/balance in the selected period @@ -165,12 +165,6 @@ class account_balance(report_sxw.rml_parse): tot_deb = 0.0 tot_crd = 0.0 tot_eje = 0.0 - if not ids: - ids = self.ids - if not ids: - return [] - if not done: - done = {} if form.has_key('account_list') and form['account_list']: account_ids = form['account_list'] @@ -182,11 +176,12 @@ class account_balance(report_sxw.rml_parse): period_obj = self.pool.get('account.period') fiscalyear_obj = self.pool.get('account.fiscalyear') - fiscalyear = None if form.get('fiscalyear'): - fiscalyear = fiscalyear_obj.browse(self.cr, self.uid, form['fiscalyear']) - else: - fiscalyear = fiscalyear_obj.browse(self.cr, self.uid, fiscalyear_obj.find(self.cr, self.uid)) + if type(form.get('fiscalyear')) in (list,tuple): + fiscalyear = form['fiscalyear'] and form['fiscalyear'][0] + elif type(form.get('fiscalyear')) in (int,): + fiscalyear = form['fiscalyear'] + fiscalyear = fiscalyear_obj.browse(self.cr, self.uid, fiscalyear) # # Get the accounts @@ -305,11 +300,6 @@ class account_balance(report_sxw.rml_parse): for account in accounts: account_id = account['id'] - if account_id in done: - pass - - done[account_id] = 1 - accounts_levels[account_id] = account['level'] # From c852dcaa803351445284069601b6ed065e6e06e7 Mon Sep 17 00:00:00 2001 From: Humberto Arocha Date: Thu, 21 Jun 2012 23:06:26 -0530 Subject: [PATCH 4/5] [FIX] Fixing gliches When making the report on v 6.0 or v 6.1 the web client send the info in a different way for each version, so this new changes makes the report agnostic of the version used v6.x --- account_financial_report/report/account_balance.py | 8 ++++---- .../report/account_balance_2_cols.py | 8 ++++---- .../report/account_balance_4_cols.py | 9 +++++---- 3 files changed, 13 insertions(+), 12 deletions(-) diff --git a/account_financial_report/report/account_balance.py b/account_financial_report/report/account_balance.py index 9bab471e..e4ea9741 100644 --- a/account_financial_report/report/account_balance.py +++ b/account_financial_report/report/account_balance.py @@ -123,11 +123,11 @@ class account_balance(report_sxw.rml_parse): return {'periods':periods_str, 'date':dates_str} def exchange_name(self, form): - self.from_currency_id = self.get_company_currency(form['company_id'] and form['company_id'][0]) + self.from_currency_id = self.get_company_currency(form['company_id'] and type(form['company_id']) in (list,tuple) and form['company_id'][0] or form['company_id']) if not form['currency_id']: self.to_currency_id = self.from_currency_id else: - self.to_currency_id = form['currency_id'] and form['currency_id'][0] + self.to_currency_id = form['currency_id'] and type(form['currency_id']) in (list, tuple) and form['currency_id'][0] or form['currency_id'] return self.pool.get('res.currency').browse(self.cr, self.uid, self.to_currency_id).name def exchange(self, from_amount): @@ -148,11 +148,11 @@ class account_balance(report_sxw.rml_parse): and the full year) """ - self.from_currency_id = self.get_company_currency(form['company_id'] and form['company_id'][0]) + self.from_currency_id = self.get_company_currency(form['company_id'] and type(form['company_id']) in (list,tuple) and form['company_id'][0] or form['company_id']) if not form['currency_id']: self.to_currency_id = self.from_currency_id else: - self.to_currency_id = form['currency_id'] and form['currency_id'][0] + self.to_currency_id = form['currency_id'] and type(form['currency_id']) in (list, tuple) and form['currency_id'][0] or form['currency_id'] tot_eje = 0.0 diff --git a/account_financial_report/report/account_balance_2_cols.py b/account_financial_report/report/account_balance_2_cols.py index 5fd17377..5e2f29ba 100644 --- a/account_financial_report/report/account_balance_2_cols.py +++ b/account_financial_report/report/account_balance_2_cols.py @@ -125,11 +125,11 @@ class account_balance(report_sxw.rml_parse): def exchange_name(self, form): - self.from_currency_id = self.get_company_currency(form['company_id'] and form['company_id'][0]) + self.from_currency_id = self.get_company_currency(form['company_id'] and type(form['company_id']) in (list,tuple) and form['company_id'][0] or form['company_id']) if not form['currency_id']: self.to_currency_id = self.from_currency_id else: - self.to_currency_id = form['currency_id'] and form['currency_id'][0] + self.to_currency_id = form['currency_id'] and type(form['currency_id']) in (list, tuple) and form['currency_id'][0] or form['currency_id'] return self.pool.get('res.currency').browse(self.cr, self.uid, self.to_currency_id).name def exchange(self, from_amount): @@ -152,11 +152,11 @@ class account_balance(report_sxw.rml_parse): """ - self.from_currency_id = self.get_company_currency(form['company_id'] and form['company_id'][0]) + self.from_currency_id = self.get_company_currency(form['company_id'] and type(form['company_id']) in (list,tuple) and form['company_id'][0] or form['company_id']) if not form['currency_id']: self.to_currency_id = self.from_currency_id else: - self.to_currency_id = form['currency_id'] and form['currency_id'][0] + self.to_currency_id = form['currency_id'] and type(form['currency_id']) in (list, tuple) and form['currency_id'][0] or form['currency_id'] tot_bin = 0.0 tot_deb = 0.0 diff --git a/account_financial_report/report/account_balance_4_cols.py b/account_financial_report/report/account_balance_4_cols.py index b131d9c2..3e72dfa9 100644 --- a/account_financial_report/report/account_balance_4_cols.py +++ b/account_financial_report/report/account_balance_4_cols.py @@ -132,11 +132,12 @@ class account_balance(report_sxw.rml_parse): return False def exchange_name(self, form): - self.from_currency_id = self.get_company_currency(form['company_id'] and form['company_id'][0]) + self.from_currency_id = self.get_company_currency(form['company_id'] and type(form['company_id']) in (list,tuple) and form['company_id'][0] or form['company_id']) if not form['currency_id']: self.to_currency_id = self.from_currency_id else: - self.to_currency_id = form['currency_id'] and form['currency_id'][0] + self.to_currency_id = form['currency_id'] and type(form['currency_id']) in (list, tuple) and form['currency_id'][0] or form['currency_id'] + name = self.pool.get('res.currency').browse(self.cr, self.uid, self.to_currency_id).name return self.pool.get('res.currency').browse(self.cr, self.uid, self.to_currency_id).name def exchange(self, from_amount): @@ -155,11 +156,11 @@ class account_balance(report_sxw.rml_parse): (account info plus debit/credit/balance in the selected period and the full year) """ - self.from_currency_id = self.get_company_currency(form['company_id'] and form['company_id'][0]) + self.from_currency_id = self.get_company_currency(form['company_id'] and type(form['company_id']) in (list,tuple) and form['company_id'][0] or form['company_id']) if not form['currency_id']: self.to_currency_id = self.from_currency_id else: - self.to_currency_id = form['currency_id'] and form['currency_id'][0] + self.to_currency_id = form['currency_id'] and type(form['currency_id']) in (list, tuple) and form['currency_id'][0] or form['currency_id'] tot_bin = 0.0 tot_deb = 0.0 From 137499037bb7d1b7f84d0f08e7382103e623db5c Mon Sep 17 00:00:00 2001 From: Humberto Arocha Date: Thu, 21 Jun 2012 23:22:45 -0530 Subject: [PATCH 5/5] [FIX] Avoiding the Total appears, When it doesn't make sense. --- account_financial_report/report/account_balance.py | 6 ++++-- account_financial_report/report/account_balance_2_cols.py | 6 ++++-- account_financial_report/report/account_balance_4_cols.py | 5 +++-- 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/account_financial_report/report/account_balance.py b/account_financial_report/report/account_balance.py index e4ea9741..6cd3077c 100644 --- a/account_financial_report/report/account_balance.py +++ b/account_financial_report/report/account_balance.py @@ -153,7 +153,8 @@ class account_balance(report_sxw.rml_parse): self.to_currency_id = self.from_currency_id else: self.to_currency_id = form['currency_id'] and type(form['currency_id']) in (list, tuple) and form['currency_id'][0] or form['currency_id'] - + + tot_check = False tot_eje = 0.0 if form.has_key('account_list') and form['account_list']: @@ -312,9 +313,10 @@ class account_balance(report_sxw.rml_parse): # Include all accounts result_acc.append(res) if form['tot_check'] and res['type'] == 'view' and res['level'] == 1 and (res['id'] not in tot): + tot_check = True tot[res['id']] = True tot_eje += res['balance'] - if form['tot_check']: + if tot_check: str_label = form['lab_str'] res2 = { 'type' : 'view', diff --git a/account_financial_report/report/account_balance_2_cols.py b/account_financial_report/report/account_balance_2_cols.py index 5e2f29ba..669dc4ae 100644 --- a/account_financial_report/report/account_balance_2_cols.py +++ b/account_financial_report/report/account_balance_2_cols.py @@ -157,7 +157,8 @@ class account_balance(report_sxw.rml_parse): self.to_currency_id = self.from_currency_id else: self.to_currency_id = form['currency_id'] and type(form['currency_id']) in (list, tuple) and form['currency_id'][0] or form['currency_id'] - + + tot_check = False tot_bin = 0.0 tot_deb = 0.0 tot_crd = 0.0 @@ -331,13 +332,14 @@ class account_balance(report_sxw.rml_parse): # Include all accounts result_acc.append(res) if form['tot_check'] and res['type'] == 'view' and res['level'] == 1 and (res['id'] not in tot): + tot_check = True tot[res['id']] = True tot_bin += res['balanceinit'] tot_deb += res['debit'] tot_crd += res['credit'] tot_eje += res['balance'] - if form['tot_check']: + if tot_check: str_label = form['lab_str'] res2 = { 'type' : 'view', diff --git a/account_financial_report/report/account_balance_4_cols.py b/account_financial_report/report/account_balance_4_cols.py index 3e72dfa9..bb6eacaa 100644 --- a/account_financial_report/report/account_balance_4_cols.py +++ b/account_financial_report/report/account_balance_4_cols.py @@ -161,7 +161,7 @@ class account_balance(report_sxw.rml_parse): self.to_currency_id = self.from_currency_id else: self.to_currency_id = form['currency_id'] and type(form['currency_id']) in (list, tuple) and form['currency_id'][0] or form['currency_id'] - + tot_check = False tot_bin = 0.0 tot_deb = 0.0 tot_crd = 0.0 @@ -348,6 +348,7 @@ class account_balance(report_sxw.rml_parse): # Include all accounts result_acc.append(res) if form['tot_check'] and res['type'] == 'view' and res['level'] == 1 and (res['id'] not in tot): + tot_check = True tot[res['id']] = True tot_bin += res['balanceinit'] tot_deb += res['debit'] @@ -355,7 +356,7 @@ class account_balance(report_sxw.rml_parse): tot_eje += res['balance'] #if (form['tot_check'] and res['type']=='view' and res['level']==1 and (res['id'] not in tot)): - if form['tot_check']: + if tot_check: str_label = form['lab_str'] res2 = { 'type' : 'view',