From 70e524fcab045dec1bc2d58cb3fcb11d5b969a16 Mon Sep 17 00:00:00 2001 From: "Vir (Open ERP)" Date: Fri, 23 Apr 2010 17:57:44 +0530 Subject: [PATCH] [ADD,MOD] account : account_compare_account_balance_report wizard converted to osv memory wizard bzr revid: vir@tinyerp.com-20100423122744-7a25ap724xppfsxx --- addons/account/__openerp__.py | 1 + addons/account/account_wizard.xml | 12 +- .../report/account_balance_landscape.py | 22 +-- .../account/report/compare_account_balance.py | 22 +-- addons/account/wizard/__init__.py | 2 +- .../account_compare_account_balance_report.py | 136 ++++++++++++++ ...nt_compare_account_balance_report_view.xml | 51 +++++ .../wizard_compare_account_balance_report.py | 175 ------------------ 8 files changed, 217 insertions(+), 204 deletions(-) create mode 100755 addons/account/wizard/account_compare_account_balance_report.py create mode 100644 addons/account/wizard/account_compare_account_balance_report_view.xml delete mode 100755 addons/account/wizard/wizard_compare_account_balance_report.py diff --git a/addons/account/__openerp__.py b/addons/account/__openerp__.py index 91f71f3b9e4..0d412f87502 100644 --- a/addons/account/__openerp__.py +++ b/addons/account/__openerp__.py @@ -76,6 +76,7 @@ module named account_voucherss 'wizard/account_balance_report_view.xml', 'wizard/account_move_line_select_view.xml', 'wizard/account_aged_trial_balance_view.xml', + 'wizard/account_compare_account_balance_report_view.xml', 'wizard/account_third_party_ledger.xml', 'project/wizard/project_account_analytic_line_view.xml', 'account_view.xml', diff --git a/addons/account/account_wizard.xml b/addons/account/account_wizard.xml index 91de16d1a12..cdd14780256 100644 --- a/addons/account/account_wizard.xml +++ b/addons/account/account_wizard.xml @@ -1,12 +1,12 @@ - + + + + + + diff --git a/addons/account/report/account_balance_landscape.py b/addons/account/report/account_balance_landscape.py index 509e5358020..a2677e46c27 100755 --- a/addons/account/report/account_balance_landscape.py +++ b/addons/account/report/account_balance_landscape.py @@ -368,15 +368,15 @@ class account_balance_landscape(rml_parse.rml_parse): self.total_for_perc=self.linesForTotal(form,ids={},doneAccount={},level=1) self.done_total=0 - for t1 in range(0,len(form['fiscalyear'][0][2])): + for t1 in range(0,len(form['fiscalyear'])): locale.setlocale(locale.LC_ALL, '') self.result_total["sum_credit" + str(t1)]=locale.format("%.2f", self.result_total["sum_credit" + str(t1)], grouping=True) self.result_total["sum_debit" + str(t1)]=locale.format("%.2f", self.result_total["sum_debit" + str(t1)], grouping=True) # self.flag=1 # self.result_total = {} - for temp in range(0,len(form['fiscalyear'][0][2])): - fy=self.pool.get('account.fiscalyear').name_get(self.cr,self.uid,form['fiscalyear'][0][2][temp]) + for temp in range(0,len(form['fiscalyear'])): + fy=self.pool.get('account.fiscalyear').name_get(self.cr,self.uid,form['fiscalyear'][temp]) years["year"+str(temp)]=fy[0][1][12:16] return [years] @@ -396,11 +396,11 @@ class account_balance_landscape(rml_parse.rml_parse): ctx = self.context.copy() result_total_parent=[] - for id in form['fiscalyear'][0][2]: + for id in form['fiscalyear']: tmp=[] ctx['fiscalyear'] = id - ctx['periods'] = form['periods'][0][2] + ctx['periods'] = form['periods'] ctx['period_manner'] = form['period_manner'] ctx['state'] = form['context'].get('state','all') tmp = self.pool.get('account.account').browse(self.cr, self.uid, ids, ctx.copy()) @@ -456,10 +456,10 @@ class account_balance_landscape(rml_parse.rml_parse): result = [] ctx = self.context.copy() tmp1=[] - for id in form['fiscalyear'][0][2]: + for id in form['fiscalyear']: ctx['fiscalyear'] = id - ctx['periods'] = form['periods'][0][2] + ctx['periods'] = form['periods'] ctx['period_manner']=form['period_manner'] ctx['state'] = form['context'].get('state','all') tmp1 = self.pool.get('account.account').browse(self.cr, self.uid, ids,ctx.copy()) @@ -575,7 +575,7 @@ class account_balance_landscape(rml_parse.rml_parse): if entry[0].child_id: - for q in range(0,len(form['fiscalyear'][0][2])): + for q in range(0,len(form['fiscalyear'])): self.baldiv["baldiv"+str(level)+str(q)]=entry[q].balance ids2 = [(x.code,x.id) for x in entry[0].child_id] @@ -583,7 +583,7 @@ class account_balance_landscape(rml_parse.rml_parse): dir=[] dir += self.lines(form, [x[1] for x in ids2], done, level+1) if dir==[]: - for w in range(0,len(form['fiscalyear'][0][2])): + for w in range(0,len(form['fiscalyear'])): if entry[w].credit <> 0.0 or entry[w].debit <> 0.0 or entry[w].balance<>0.00: dont_pop=1 break @@ -601,9 +601,9 @@ class account_balance_landscape(rml_parse.rml_parse): def get_years(self,form): result =[] res={} - for temp in range(0,len(form['fiscalyear'][0][2])): + for temp in range(0,len(form['fiscalyear'])): res={} - fy=self.pool.get('account.fiscalyear').name_get(self.cr,self.uid,form['fiscalyear'][0][2][temp]) + fy=self.pool.get('account.fiscalyear').name_get(self.cr,self.uid,form['fiscalyear'][temp]) res['year']=fy[0][1] res['last_str']=temp diff --git a/addons/account/report/compare_account_balance.py b/addons/account/report/compare_account_balance.py index 52205055298..28054377834 100755 --- a/addons/account/report/compare_account_balance.py +++ b/addons/account/report/compare_account_balance.py @@ -368,15 +368,15 @@ class account_balance(report_sxw.rml_parse): self.total_for_perc=self.linesForTotal(form,ids={},doneAccount={},level=1) self.done_total=0 - for t1 in range(0,len(form['fiscalyear'][0][2])): + for t1 in range(0,len(form['fiscalyear'])): locale.setlocale(locale.LC_ALL, '') self.result_total["sum_credit" + str(t1)]=locale.format("%.2f", self.result_total["sum_credit" + str(t1)], grouping=True) self.result_total["sum_debit" + str(t1)]=locale.format("%.2f", self.result_total["sum_debit" + str(t1)], grouping=True) # self.flag=1 # self.result_total = {} - for temp in range(0,len(form['fiscalyear'][0][2])): - fy=self.pool.get('account.fiscalyear').name_get(self.cr,self.uid,form['fiscalyear'][0][2][temp]) + for temp in range(0,len(form['fiscalyear'])): + fy=self.pool.get('account.fiscalyear').name_get(self.cr,self.uid,form['fiscalyear'][temp]) years["year"+str(temp)]=fy[0][1][12:16] return [years] @@ -395,11 +395,11 @@ class account_balance(report_sxw.rml_parse): ctx = self.context.copy() result_total_parent=[] - for id in form['fiscalyear'][0][2]: + for id in form['fiscalyear']: tmp=[] ctx['fiscalyear'] = id - ctx['periods'] = form['periods'][0][2] + ctx['periods'] = form['periods'] ctx['period_manner'] = form['period_manner'] ctx['state'] = form['context'].get('state','all') tmp = self.pool.get('account.account').browse(self.cr, self.uid, ids, ctx.copy()) @@ -453,10 +453,10 @@ class account_balance(report_sxw.rml_parse): result = [] ctx = self.context.copy() tmp1=[] - for id in form['fiscalyear'][0][2]: + for id in form['fiscalyear']: ctx['fiscalyear'] = id - ctx['periods'] = form['periods'][0][2] + ctx['periods'] = form['periods'] ctx['period_manner']=form['period_manner'] ctx['state'] = form['context'].get('state','all') tmp1 = self.pool.get('account.account').browse(self.cr, self.uid, ids,ctx.copy()) @@ -571,7 +571,7 @@ class account_balance(report_sxw.rml_parse): if entry[0].child_id: - for q in range(0,len(form['fiscalyear'][0][2])): + for q in range(0,len(form['fiscalyear'])): self.baldiv["baldiv"+str(level)+str(q)]=entry[q].balance ids2 = [(x.code,x.id) for x in entry[0].child_id] @@ -579,7 +579,7 @@ class account_balance(report_sxw.rml_parse): dir=[] dir += self.lines(form, [x[1] for x in ids2], done, level+1) if dir==[]: - for w in range(0,len(form['fiscalyear'][0][2])): + for w in range(0,len(form['fiscalyear'])): if entry[w].credit <> 0.0 or entry[w].debit <> 0.0 or entry[w].balance<>0.00: dont_pop=1 break @@ -597,9 +597,9 @@ class account_balance(report_sxw.rml_parse): def get_years(self,form): result =[] res={} - for temp in range(0,len(form['fiscalyear'][0][2])): + for temp in range(0,len(form['fiscalyear'])): res={} - fy=self.pool.get('account.fiscalyear').name_get(self.cr,self.uid,form['fiscalyear'][0][2][temp]) + fy=self.pool.get('account.fiscalyear').name_get(self.cr,self.uid,form['fiscalyear'][temp]) res['year']=fy[0][1] res['last_str']=temp diff --git a/addons/account/wizard/__init__.py b/addons/account/wizard/__init__.py index 836eeea512f..91fb10e5205 100644 --- a/addons/account/wizard/__init__.py +++ b/addons/account/wizard/__init__.py @@ -41,7 +41,7 @@ import account_fiscalyear_close_state import account_vat import account_open_closed_fiscalyear -import wizard_compare_account_balance_report +import account_compare_account_balance_report import account_invoice_state import account_chart import account_move_line_select diff --git a/addons/account/wizard/account_compare_account_balance_report.py b/addons/account/wizard/account_compare_account_balance_report.py new file mode 100755 index 00000000000..fd1d4d55ada --- /dev/null +++ b/addons/account/wizard/account_compare_account_balance_report.py @@ -0,0 +1,136 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# OpenERP, Open Source Management Solution +# Copyright (C) 2004-2010 Tiny SPRL (). +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . +# +############################################################################## + +import time + +from osv import osv, fields +from tools.translate import _ + +class account_compare_account_balance_report(osv.osv_memory): + """ + This wizard will provide the account balance comparision report by fiscal years. + """ + _name = 'account.compare.account.balance.report' + _description = 'Account Balance Report' + _columns = { + 'fiscalyear': fields.many2many('account.fiscalyear', 'account_fiscalyear_rel','account_id','fiscalyear_id','Fiscal year', help='Keep empty for all open fiscal year'), + 'select_account': fields.many2one('account.account','Select Reference Account(for % comparision)',help='Keep empty for comparision to its parent'), + 'account_choice': fields.selection([('all','All accounts'), + ('bal_zero','With balance is not equal to 0'), + ('moves','With movements')],'Show Accounts'), + 'show_columns': fields.boolean('Show Debit/Credit Information'), + 'landscape': fields.boolean('Show Report in Landscape Form'), + 'format_perc': fields.boolean('Show Comparision in %'), + 'compare_pattern': fields.selection([('bal_cash','Cash'), + ('bal_perc','Percentage'), + ('none','Don'+ "'" +'t Compare')],'Compare Selected Years In Terms Of'), + 'period_manner': fields.selection([('actual','Financial Period'),('created','Creation Date')],'Entries Selection Based on'), + 'periods': fields.many2many('account.period', 'period_account_balance_rel', + 'report_id', 'period_id', 'Periods', + help='Keep empty for all open fiscal year'), + } + + _defaults={ + 'compare_pattern': 'none', + 'account_choice': 'moves', + 'period_manner': 'actual', + } + + def check(self, cr, uid, ids, context=None): + data={} + if context is None: + context = {} + data = { + 'ids':context['active_ids'], + 'form': self.read(cr, uid, ids, ['fiscalyear', 'select_account', 'account_choice', 'periods', 'show_columns', 'landscape', 'format_perc','compare_pattern','period_manner'])[0], + } + + data['form']['context'] = context + if (len(data['form']['fiscalyear'])==0) or (len(data['form']['fiscalyear'])>1 and (data['form']['compare_pattern']!='none') and (data['form']['format_perc']==1) and (data['form']['show_columns']==1) and (data['form']['landscape']!=1)): + raise osv.except_osv(_('Warning !'), _('You have to select at least 1 Fiscal Year. \nYou may have selected the compare options with more than 1 year with credit/debit columns and % option.This can lead contents to be printed out of the paper.Please try again.')) + + + if ((len(data['form']['fiscalyear'])==3) and (data['form']['format_perc']!=1) and (data['form']['show_columns']!=1)): + if data['form']['landscape']==1: + return { + 'type': 'ir.actions.report.xml', + 'report_name': 'account.account.balance.landscape', + 'datas': data, + } + else: + return { + 'type': 'ir.actions.report.xml', + 'report_name': 'account.balance.account.balance', + 'datas': data, + } + if data['form']['format_perc']==1: + if len(data['form']['fiscalyear'])<=2: + if data['form']['landscape']==1: + return { + 'type': 'ir.actions.report.xml', + 'report_name': 'account.account.balance.landscape', + 'datas': data, + } + else: + return { + 'type': 'ir.actions.report.xml', + 'report_name': 'account.balance.account.balance', + 'datas': data, + } + else: + if len(data['form']['fiscalyear'])==3: + if data['form']['landscape']==1: + return { + 'type': 'ir.actions.report.xml', + 'report_name': 'account.account.balance.landscape', + 'datas': data, + } + else: + raise osv.except_osv(_('Warning !'), _('You might have done following mistakes. Please correct them and try again. \n 1. You have selected more than 3 years in any case. \n 2. You have not selected Percentage option, but you have selected more than 2 years. \n You can select maximum 3 years. Please check again. \n 3. You have selected Percentage option with more than 2 years, but you have not selected landscape format. You have to select Landscape option. Please Check it.')) + else: + raise osv.except_osv(_('Warning !'), _('You might have done following mistakes. Please correct them and try again. \n 1. You have selected more than 3 years in any case. \n 2. You have not selected Percentage option, but you have selected more than 2 years. \n You can select maximum 3 years. Please check again. \n 3. You have selected Percentage option with more than 2 years, but you have not selected landscape format. You have to select Landscape option. Please Check it.')) + else: + if len(data['form']['fiscalyear'])>2: + if data['form']['landscape']==1: + return { + 'type': 'ir.actions.report.xml', + 'report_name': 'account.account.balance.landscape', + 'datas': data, + } + else: + raise osv.except_osv(_('Warning !'), _('You might have done following mistakes. Please correct them and try again. \n 1. You have selected more than 3 years in any case. \n 2. You have not selected Percentage option, but you have selected more than 2 years. \n You can select maximum 3 years. Please check again. \n 3. You have selected Percentage option with more than 2 years, but you have not selected landscape format. You have to select Landscape option. Please Check it.')) + else: + if data['form']['landscape']==1: + return { + 'type': 'ir.actions.report.xml', + 'report_name': 'account.account.balance.landscape', + 'datas': data, + } + else: + return { + 'type': 'ir.actions.report.xml', + 'report_name': 'account.balance.account.balance', + 'datas': data, + } +account_compare_account_balance_report() + +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: + diff --git a/addons/account/wizard/account_compare_account_balance_report_view.xml b/addons/account/wizard/account_compare_account_balance_report_view.xml new file mode 100644 index 00000000000..e153d11bfaa --- /dev/null +++ b/addons/account/wizard/account_compare_account_balance_report_view.xml @@ -0,0 +1,51 @@ + + + + + + account.compare.account.balance.report.form + account.compare.account.balance.report + form + +
+ + + + + + + + + + + + + + +