From 4c1f1aa6e74c47975adc2b1f3db04450d56f3d3f Mon Sep 17 00:00:00 2001 From: Humberto Arocha Date: Thu, 26 Jul 2012 23:57:31 -0530 Subject: [PATCH 01/49] [IMP] Generado un solo parser para todo los reportes financieros [TODO] Unir aqui tambien al mayor analitico --- account_financial_report/report/__init__.py | 4 +- account_financial_report/report/parser.py | 390 ++++++++++++++++++++ 2 files changed, 391 insertions(+), 3 deletions(-) create mode 100644 account_financial_report/report/parser.py diff --git a/account_financial_report/report/__init__.py b/account_financial_report/report/__init__.py index 04b658b8..5eadef5a 100644 --- a/account_financial_report/report/__init__.py +++ b/account_financial_report/report/__init__.py @@ -25,6 +25,4 @@ # along with this program. If not, see . ############################################################################## -import account_balance -import account_balance_4_cols -import account_balance_2_cols +import parser diff --git a/account_financial_report/report/parser.py b/account_financial_report/report/parser.py new file mode 100644 index 00000000..aa2cbc83 --- /dev/null +++ b/account_financial_report/report/parser.py @@ -0,0 +1,390 @@ +# -*- encoding: utf-8 -*- +########################################################################### +# Module Writen to OpenERP, Open Source Management Solution +# Copyright (C) OpenERP Venezuela (). +# All Rights Reserved +###############Credits###################################################### +# Coded by: Humberto Arocha humberto@openerp.com.ve +# Angelica Barrios angelicaisabelb@gmail.com +# Jordi Esteve +# Javier Duran +# Planified by: Humberto Arocha +# Finance by: LUBCAN COL S.A.S http://www.lubcancol.com +# Audited by: Humberto Arocha humberto@openerp.com.ve +############################################################################# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU 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 General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +############################################################################## + +import xml +import copy +from operator import itemgetter +import time +import datetime +from report import report_sxw +from tools import config +from tools.translate import _ + +class account_balance(report_sxw.rml_parse): + + def __init__(self, cr, uid, name, context): + super(account_balance, self).__init__(cr, uid, name, context) + self.sum_debit = 0.00 + self.sum_credit = 0.00 + self.sum_balance = 0.00 + self.sum_debit_fy = 0.00 + self.sum_credit_fy = 0.00 + self.sum_balance_fy = 0.00 + self.date_lst = [] + self.date_lst_string = '' + self.localcontext.update({ + 'time': time, + 'lines': self.lines, + 'get_fiscalyear_text': self.get_fiscalyear_text, + '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 + + + def get_fiscalyear_text(self, form): + """ + Returns the fiscal year text used on the report. + """ + fiscalyear_obj = self.pool.get('account.fiscalyear') + fiscalyear = None + if form.get('fiscalyear'): + fiscalyear = fiscalyear_obj.browse(self.cr, self.uid, form['fiscalyear']) + return fiscalyear.name or fiscalyear.code + else: + fiscalyear = fiscalyear_obj.browse(self.cr, self.uid, fiscalyear_obj.find(self.cr, self.uid)) + return "%s*" % (fiscalyear.name or fiscalyear.code) + + def get_informe_text(self, form): + """ + Returns the header text used on the report. + """ + inf_type = { + 'bgen' : ' Balance General', + 'bcom' : ' Balance de Comprobacion', + 'edogp': 'Estado de Ganancias y Perdidas', + 'bml': 'Libro Mayor Legal', + 'bdl' : 'Diario Legal' + } + return inf_type[form['inf_type']] + + def get_month(self, form): + ''' + return day, year and month + ''' + if form['filter'] in ['bydate', 'all']: + months=["Enero","Febrero","Marzo","Abril","Mayo","Junio","Julio","Agosto","Septiembre","Octubre","Noviembre","Diciembre"] + mes = months[time.strptime(form['date_to'],"%Y-%m-%d")[1]-1] + ano = time.strptime(form['date_to'],"%Y-%m-%d")[0] + dia = time.strptime(form['date_to'],"%Y-%m-%d")[2] + return 'Período del '+self.formatLang(form['date_from'], date=True)+' al '+self.formatLang(form['date_to'], date=True) + elif form['filter'] in ['byperiod', 'all']: + aux=[] + period_obj = self.pool.get('account.period') + + for period in period_obj.browse(self.cr, self.uid, form['periods']): + aux.append(period.date_start) + aux.append(period.date_stop) + sorted(aux) + return _('Período del ')+self.formatLang(aux[0], date=True)+_(' al ')+self.formatLang(aux[-1], date=True) + + def get_periods_and_date_text(self, form): + """ + Returns the text with the periods/dates used on the report. + """ + period_obj = self.pool.get('account.period') + periods_str = None + fiscalyear_id = form['fiscalyear'] or fiscalyear_obj.find(self.cr, self.uid) + period_ids = period_obj.search(self.cr, self.uid, [('fiscalyear_id','=',fiscalyear_id),('special','=',False)]) + if form['filter'] in ['byperiod', 'all']: + period_ids = form['periods'] + periods_str = ', '.join([period.name or period.code for period in period_obj.browse(self.cr, self.uid, period_ids)]) + + dates_str = None + if form['filter'] in ['bydate', 'all']: + dates_str = self.formatLang(form['date_from'], date=True) + ' - ' + self.formatLang(form['date_to'], date=True) + ' ' + 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 exchange_name(self, form): + 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 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): + 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, 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 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 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 + tot_eje = 0.0 + + if form.has_key('account_list') and form['account_list']: + account_ids = form['account_list'] + del form['account_list'] + res = {} + result_acc = [] + accounts_levels = {} + account_obj = self.pool.get('account.account') + period_obj = self.pool.get('account.period') + fiscalyear_obj = self.pool.get('account.fiscalyear') + + if form.get('fiscalyear'): + 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 + # + + def _get_children_and_consol(cr, uid, ids, level, context={}): + aa_obj = self.pool.get('account.account') + ids2=[] + temp=[] + read_data= aa_obj.read(cr, uid, ids,['id','child_id','level','type'], context) + for data in read_data: + if data['child_id'] and data['level'] < level and data['type']!='consolidation': + ids2.append([data['id'],True, False]) + temp=[] + for x in data['child_id']: + temp.append(x) + ids2 += _get_children_and_consol(cr, uid, temp, level, context) + ids2.append([data['id'],False,True]) + else: + ids2.append([data['id'],True,True]) + return ids2 + + child_ids = _get_children_and_consol(self.cr, self.uid, account_ids, form['display_account_level'] and form['display_account_level'] or 100,self.context) + if child_ids: + account_ids = child_ids + + account_obj = self.pool.get('account.account') + period_obj = self.pool.get('account.period') + fiscalyear_obj = self.pool.get('account.fiscalyear') + + ############################################################################# + # Calculate the period Debit/Credit # + # (from the selected period or all the non special periods in the fy) # + ############################################################################# + + 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)]) + + if ctx['filter'] not in ['bydate','none']: + special = self.special_period(form['periods']) + else: + special = False + + if form['filter'] in ['byperiod', 'all']: + if special: + ctx['periods'] = period_obj.search(self.cr, self.uid, [('id','in',form['periods'] or ctx.get('periods',False))]) + else: + ctx['periods'] = period_obj.search(self.cr, self.uid, [('id','in',form['periods'] or ctx.get('periods',False)),('special','=',False)]) + + if form['filter'] in ['bydate','all','none']: + ctx['date_from'] = form['date_from'] + ctx['date_to'] = form['date_to'] + + accounts=[] + + val = account_obj.browse(self.cr, self.uid, [aa_id[0] for aa_id in account_ids], ctx) + c = 0 + for aa_id in account_ids: + new_acc = { + 'id' :val[c].id, + 'type' :val[c].type, + 'code' :val[c].code, + 'name' :val[c].name, + 'debit' :val[c].debit, + 'credit' :val[c].credit, + 'parent_id' :val[c].parent_id and val[c].parent_id.id, + 'level' :val[c].level, + 'label' :aa_id[1], + 'total' :aa_id[2], + } + c += 1 + accounts.append(new_acc) + + def missing_period(): + ctx['fiscalyear'] = fiscalyear_obj.search(self.cr, self.uid, [('date_stop','<',fiscalyear.date_start)],order='date_stop') and \ + fiscalyear_obj.search(self.cr, self.uid, [('date_stop','<',fiscalyear.date_start)],order='date_stop')[-1] or [] + ctx['periods'] = period_obj.search(self.cr, self.uid, [('fiscalyear_id','=',ctx['fiscalyear']),('date_stop','<',fiscalyear.date_start)]) + + ############################################################################# + # Calculate the period initial Balance # + # (fy balance minus the balance from the start of the selected period # + # to the end of the year) # + ############################################################################# + + ctx = self.context.copy() + ctx['filter'] = form.get('filter','all') + ctx['fiscalyear'] = fiscalyear.id + + if form['filter'] in ['byperiod', 'all']: + ctx['periods'] = form['periods'] + date_start = min([period.date_start for period in period_obj.browse(self.cr, self.uid, ctx['periods'])]) + ctx['periods'] = period_obj.search(self.cr, self.uid, [('fiscalyear_id','=',fiscalyear.id),('date_stop','<=',date_start)]) + if not ctx['periods']: + missing_period() + elif form['filter'] in ['bydate']: + ctx['date_from'] = fiscalyear.date_start + ctx['date_to'] = form['date_from'] + ctx['periods'] = period_obj.search(self.cr, self.uid, [('fiscalyear_id','=',fiscalyear.id),('date_stop','<=',ctx['date_to'])]) + elif form['filter'] == 'none': + ctx['periods'] = period_obj.search(self.cr, self.uid, [('fiscalyear_id','=',fiscalyear.id),('special','=',True)]) + date_start = min([period.date_start for period in period_obj.browse(self.cr, self.uid, ctx['periods'])]) + ctx['periods'] = period_obj.search(self.cr, self.uid, [('fiscalyear_id','=',fiscalyear.id),('date_start','<=',date_start),('special','=',True)]) + + period_balanceinit = {} + for acc in account_obj.browse(self.cr, self.uid, [x[0] for x in account_ids], ctx): + if special: + period_balanceinit[acc['id']] = 0.0 + else: + period_balanceinit[acc['id']] = acc.balance + # + # Generate the report lines (checking each account) + # + tot = {} + for account in accounts: + account_id = account['id'] + + accounts_levels[account_id] = account['level'] + + # + # Check if we need to include this level + # + if not form['display_account_level'] or account['level'] <= form['display_account_level']: + # + # Copy the account values + # + res = { + 'id' : account_id, + 'type' : account['type'], + 'code': account['code'], + 'name': (account['total'] and not account['label']) and 'TOTAL %s'%(account['name'].upper()) or account['name'], + 'level': account['level'], + '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'], + 'total': account['total'], + } + # + # Round the values to zero if needed (-0.000001 ~= 0) + # + + if abs(res['balance']) < 0.5 * 10**-4: + res['balance'] = 0.0 + + # + # Check whether we must include this line in the report or not + # + + if form['display_account'] == 'con_movimiento' and account['parent_id']: + # Include accounts with movements + 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 + if abs(res['balance']) >= 0.5 * 10**-4: + result_acc.append(res) + else: + # 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'] and res['type']=='view' and res['level']==1 and (res['id'] not in tot)): + if tot_check: + str_label = form['lab_str'] + res2 = { + 'type' : 'view', + 'name': 'TOTAL %s'%(str_label), + 'balanceinit': tot_bin, + 'debit': tot_deb, + 'credit': tot_crd, + 'balance': tot_eje, + 'label': False, + 'total': True, + } + result_acc.append(res2) + return result_acc + + +report_sxw.report_sxw('report.wizard.report.reporte', + 'wizard.report', + 'account_financial_report/report/balance_full_4_cols.rml', + parser=account_balance, + header=False) + +report_sxw.report_sxw('report.account.account.balance.gene.2', + 'wizard.report.account.balance.gene.2', + 'account_financial_report/report/balance_full_2_cols.rml', + parser=account_balance, + header=False) + +report_sxw.report_sxw('report.account.account.balance.gene', + 'wizard.report.account.balance.gene', + 'account_financial_report/report/balance_full.rml', + parser=account_balance, + header=False) From 93870589ea224dd3dd5f99b0de6b35d7d8df822a Mon Sep 17 00:00:00 2001 From: Humberto Arocha Date: Fri, 27 Jul 2012 00:22:37 -0530 Subject: [PATCH 02/49] [RM] Delete unneeded parsers for account_financial_report --- .../report/account_balance.py | 334 ---------------- .../report/account_balance_2_cols.py | 360 ----------------- .../report/account_balance_4_cols.py | 377 ------------------ 3 files changed, 1071 deletions(-) delete mode 100644 account_financial_report/report/account_balance.py delete mode 100644 account_financial_report/report/account_balance_2_cols.py delete mode 100644 account_financial_report/report/account_balance_4_cols.py diff --git a/account_financial_report/report/account_balance.py b/account_financial_report/report/account_balance.py deleted file mode 100644 index 6cd3077c..00000000 --- a/account_financial_report/report/account_balance.py +++ /dev/null @@ -1,334 +0,0 @@ -# -*- encoding: utf-8 -*- -########################################################################### -# Module Writen to OpenERP, Open Source Management Solution -# Copyright (C) OpenERP Venezuela (). -# All Rights Reserved -###############Credits###################################################### -# Coded by: Humberto Arocha humberto@openerp.com.ve -# Angelica Barrios angelicaisabelb@gmail.com -# Jordi Esteve -# Javier Duran -# Planified by: Humberto Arocha -# Finance by: LUBCAN COL S.A.S http://www.lubcancol.com -# Audited by: Humberto Arocha humberto@openerp.com.ve -############################################################################# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU 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 General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . -############################################################################## - -import xml -import copy -from operator import itemgetter -import time -import datetime -from report import report_sxw -from tools import config - - -class account_balance(report_sxw.rml_parse): - - - def __init__(self, cr, uid, name, context): - super(account_balance, self).__init__(cr, uid, name, context) - self.sum_debit = 0.00 - self.sum_credit = 0.00 - self.sum_balance = 0.00 - self.sum_debit_fy = 0.00 - self.sum_credit_fy = 0.00 - self.sum_balance_fy = 0.00 - self.date_lst = [] - self.date_lst_string = '' - self.localcontext.update({ - 'time': time, - 'lines': self.lines, - 'get_fiscalyear_text': self.get_fiscalyear_text, - '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 - - - def get_fiscalyear_text(self, form): - """ - Returns the fiscal year text used on the report. - """ - fiscalyear_obj = self.pool.get('account.fiscalyear') - fiscalyear = None - if form.get('fiscalyear'): - fiscalyear = fiscalyear_obj.browse(self.cr, self.uid, form['fiscalyear']) - return fiscalyear.name or fiscalyear.code - else: - fiscalyear = fiscalyear_obj.browse(self.cr, self.uid, fiscalyear_obj.find(self.cr, self.uid)) - return "%s*" % (fiscalyear.name or fiscalyear.code) - - def get_month(self, form): - ''' - return day, year and month - ''' - if form['filter'] in ['bydate', 'all']: - months=["Enero","Febrero","Marzo","Abril","Mayo","Junio","Julio","Agosto","Septiembre","Octubre","Noviembre","Diciembre"] - mes = months[time.strptime(form['date_to'],"%Y-%m-%d")[1]-1] - ano = time.strptime(form['date_to'],"%Y-%m-%d")[0] - dia = time.strptime(form['date_to'],"%Y-%m-%d")[2] - return 'Período del '+self.formatLang(form['date_from'], date=True)+' al '+self.formatLang(form['date_to'], date=True) - elif form['filter'] in ['byperiod', 'all']: - aux=[] - period_obj = self.pool.get('account.period') - - for period in period_obj.browse(self.cr, self.uid, form['periods']): - aux.append(period.date_start) - aux.append(period.date_stop) - sorted(aux) - return 'Período del '+self.formatLang(aux[0], date=True)+' al '+self.formatLang(aux[-1], date=True) - - def get_informe_text(self, form): - """ - Returns the header text used on the report. - """ - inf_type = { - 'bgen' : ' Balance General', - 'bcom' : ' Balance de Comprobacion', - 'edogp': 'Estado de Ganancias y Perdidas' - } - return inf_type[form['inf_type']] - - def get_periods_and_date_text(self, form): - """ - Returns the text with the periods/dates used on the report. - """ - period_obj = self.pool.get('account.period') - periods_str = None - fiscalyear_id = form['fiscalyear'] or fiscalyear_obj.find(self.cr, self.uid) - period_ids = period_obj.search(self.cr, self.uid, [('fiscalyear_id','=',fiscalyear_id),('special','=',False)]) - if form['filter'] in ['byperiod', 'all']: - period_ids = form['periods'] - periods_str = ', '.join([period.name or period.code for period in period_obj.browse(self.cr, self.uid, period_ids)]) - - dates_str = None - if form['filter'] in ['bydate', 'all']: - dates_str = self.formatLang(form['date_from'], date=True) + ' - ' + self.formatLang(form['date_to'], date=True) + ' ' - - return {'periods':periods_str, 'date':dates_str} - - def exchange_name(self, form): - 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 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): - 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, 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 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 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']: - account_ids = form['account_list'] - del form['account_list'] - res = {} - result_acc = [] - accounts_levels = {} - account_obj = self.pool.get('account.account') - period_obj = self.pool.get('account.period') - fiscalyear_obj = self.pool.get('account.fiscalyear') - - # Get the fiscal year - if form.get('fiscalyear'): - 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 - # - def _get_children_and_consol(cr, uid, ids, level, context={}): - aa_obj = self.pool.get('account.account') - ids2=[] - temp=[] - read_data= aa_obj.read(cr, uid, ids,['id','child_id','level','type'], context) - for data in read_data: - if data['child_id'] and data['level'] < level and data['type']!='consolidation': - #ids2.append([data['id'],'Label', 'Total']) - ids2.append([data['id'],True, False]) - temp=[] - for x in data['child_id']: - temp.append(x) - ids2 += _get_children_and_consol(cr, uid, temp, level, context) - ids2.append([data['id'],False,True]) - else: - ids2.append([data['id'],True,True]) - return ids2 - - child_ids = _get_children_and_consol(self.cr, self.uid, account_ids, form['display_account_level'] and form['display_account_level'] or 100,self.context) - if child_ids: - account_ids = child_ids - - # - # Calculate the FY Balance. - # (from full fiscal year without closing periods) - # - ctx = self.context.copy() - if form.get('fiscalyear'): - # Use only the current fiscal year - ctx['fiscalyear'] = fiscalyear.id - ctx['periods'] = period_obj.search(self.cr, self.uid, [('fiscalyear_id','=',fiscalyear.id),'|',('special','=',False),('date_stop','<',fiscalyear.date_stop)]) - else: - # Use all the open fiscal years - open_fiscalyear_ids = fiscalyear_obj.search(self.cr, self.uid, [('filter','=','draft')]) - ctx['periods'] = period_obj.search(self.cr, self.uid, [('fiscalyear_id','in',open_fiscalyear_ids),'|',('special','=',False),('date_stop','<',fiscalyear.date_stop)]) - - fy_balance = {} - for acc in account_obj.read(self.cr, self.uid, [x[0] for x in account_ids], ['balance'], ctx): - fy_balance[acc['id']] = acc['balance'] - # - # Calculate the FY Debit/Credit - # (from full fiscal year without opening or closing periods) - # - ctx = self.context.copy() - ctx['fiscalyear'] = fiscalyear.id - ctx['periods'] = period_obj.search(self.cr, self.uid, [('fiscalyear_id','=',fiscalyear.id),('special','=',False)]) - - # - # Calculate the period Debit/Credit - # (from the selected period or all the non special periods in the fy) - # - 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)]) - if form['filter'] in ['byperiod', 'all']: - ctx['periods'] = form['periods'] - if form['filter'] in ['bydate', 'all']: - ctx['date_from'] = form['date_from'] - ctx['date_to'] = form['date_to'] - - accounts=[] - val = account_obj.browse(self.cr, self.uid, [aa_id[0] for aa_id in account_ids], ctx) - c = 0 - for aa_id in account_ids: - new_acc = { - 'id' :val[c].id, - 'type' :val[c].type, - 'code' :val[c].code, - 'name' :val[c].name, - 'balance' :val[c].balance, - 'parent_id' :val[c].parent_id and val[c].parent_id.id, - 'level' :val[c].level, - 'label' :aa_id[1], - 'total' :aa_id[2], - } - c += 1 - accounts.append(new_acc) - - # - # Generate the report lines (checking each account) - # - tot = {} - for account in accounts: - account_id = account['id'] - - # - # Calculate the account level - # - - accounts_levels[account_id] = account['level'] - - # - # Check if we need to include this level - # - if not form['display_account_level'] or account['level'] <= form['display_account_level']: - # - # Copy the account values - # - res = { - 'id' : account_id, - 'type' : account['type'], - 'code': account['code'], - 'name': (account['total'] and not account['label']) and 'TOTAL %s'%(account['name'].upper()) or account['name'], - 'level': account['level'], - 'balance': self.exchange(account['balance']), - 'parent_id': account['parent_id'], - 'bal_type': '', - 'label': account['label'], - 'total': account['total'], - } - - # - # Round the values to zero if needed (-0.000001 ~= 0) - # - - if abs(res['balance']) < 0.5 * 10**-int(2): - res['balance'] = 0.0 - - # - # Check whether we must include this line in the report or not - # - - if form['display_account'] == 'con_movimiento' and account['parent_id']: - # Include accounts with movements - if abs(res['balance']) >= 0.5 * 10**-int(2): - result_acc.append(res) - elif form['display_account'] == 'con_balance' and account['parent_id']: - # Include accounts with balance - if abs(res['balance']) >= 0.5 * 10**-int(2): - result_acc.append(res) - else: - # 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 tot_check: - str_label = form['lab_str'] - res2 = { - 'type' : 'view', - 'name': 'TOTAL %s'%(str_label), - 'balance': self.exchange(tot_eje), - 'label': False, - 'total': True, - } - result_acc.append(res2) - return result_acc -report_sxw.report_sxw('report.account.account.balance.gene', - 'wizard.report.account.balance.gene', - 'account_financial_report/report/balance_full.rml', - parser=account_balance, - header=False) diff --git a/account_financial_report/report/account_balance_2_cols.py b/account_financial_report/report/account_balance_2_cols.py deleted file mode 100644 index 669dc4ae..00000000 --- a/account_financial_report/report/account_balance_2_cols.py +++ /dev/null @@ -1,360 +0,0 @@ -# -*- encoding: utf-8 -*- -########################################################################### -# Module Writen to OpenERP, Open Source Management Solution -# Copyright (C) OpenERP Venezuela (). -# All Rights Reserved -###############Credits###################################################### -# Coded by: Humberto Arocha humberto@openerp.com.ve -# Angelica Barrios angelicaisabelb@gmail.com -# Jordi Esteve -# Javier Duran -# Planified by: Humberto Arocha -# Finance by: LUBCAN COL S.A.S http://www.lubcancol.com -# Audited by: Humberto Arocha humberto@openerp.com.ve -############################################################################# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU 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 General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . -############################################################################## - -import xml -import copy -from operator import itemgetter -import time -import datetime -from report import report_sxw -from tools import config - - -class account_balance(report_sxw.rml_parse): - - - def __init__(self, cr, uid, name, context): - super(account_balance, self).__init__(cr, uid, name, context) - self.sum_debit = 0.00 - self.sum_credit = 0.00 - self.sum_balance = 0.00 - self.sum_debit_fy = 0.00 - self.sum_credit_fy = 0.00 - self.sum_balance_fy = 0.00 - self.date_lst = [] - self.date_lst_string = '' - self.localcontext.update({ - 'time': time, - 'lines': self.lines, - 'get_fiscalyear_text': self.get_fiscalyear_text, - '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 - - - def get_fiscalyear_text(self, form): - """ - Returns the fiscal year text used on the report. - """ - fiscalyear_obj = self.pool.get('account.fiscalyear') - fiscalyear = None - if form.get('fiscalyear'): - fiscalyear = fiscalyear_obj.browse(self.cr, self.uid, form['fiscalyear']) - return fiscalyear.name or fiscalyear.code - else: - fiscalyear = fiscalyear_obj.browse(self.cr, self.uid, fiscalyear_obj.find(self.cr, self.uid)) - return "%s*" % (fiscalyear.name or fiscalyear.code) - - def get_informe_text(self, form): - """ - Returns the header text used on the report. - """ - inf_type = { - 'bgen' : ' Balance General', - 'bcom' : ' Balance de Comprobacion', - 'edogp': 'Estado de Ganancias y Perdidas', - 'bdl' : 'Diario Legal' - } - return inf_type[form['inf_type']] - - def get_month(self, form): - ''' - return day, year and month - ''' - if form['filter'] in ['bydate', 'all']: - months=["Enero","Febrero","Marzo","Abril","Mayo","Junio","Julio","Agosto","Septiembre","Octubre","Noviembre","Diciembre"] - mes = months[time.strptime(form['date_to'],"%Y-%m-%d")[1]-1] - ano = time.strptime(form['date_to'],"%Y-%m-%d")[0] - dia = time.strptime(form['date_to'],"%Y-%m-%d")[2] - return 'Período del '+self.formatLang(form['date_from'], date=True)+' al '+self.formatLang(form['date_to'], date=True) - elif form['filter'] in ['byperiod', 'all']: - aux=[] - period_obj = self.pool.get('account.period') - - for period in period_obj.browse(self.cr, self.uid, form['periods']): - aux.append(period.date_start) - aux.append(period.date_stop) - sorted(aux) - return 'Período del '+self.formatLang(aux[0], date=True)+' al '+self.formatLang(aux[-1], date=True) - - def get_periods_and_date_text(self, form): - """ - Returns the text with the periods/dates used on the report. - """ - period_obj = self.pool.get('account.period') - periods_str = None - fiscalyear_id = form['fiscalyear'] or fiscalyear_obj.find(self.cr, self.uid) - period_ids = period_obj.search(self.cr, self.uid, [('fiscalyear_id','=',fiscalyear_id),('special','=',False)]) - if form['filter'] in ['byperiod', 'all']: - period_ids = form['periods'] - periods_str = ', '.join([period.name or period.code for period in period_obj.browse(self.cr, self.uid, period_ids)]) - - dates_str = None - if form['filter'] in ['bydate', 'all']: - dates_str = self.formatLang(form['date_from'], date=True) + ' - ' + self.formatLang(form['date_to'], date=True) + ' ' - return {'periods':periods_str, 'date':dates_str} - - - - def exchange_name(self, form): - 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 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): - 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, 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 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 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 - tot_eje = 0.0 - - if form.has_key('account_list') and form['account_list']: - account_ids = form['account_list'] - del form['account_list'] - res = {} - result_acc = [] - accounts_levels = {} - account_obj = self.pool.get('account.account') - period_obj = self.pool.get('account.period') - fiscalyear_obj = self.pool.get('account.fiscalyear') - - if form.get('fiscalyear'): - 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 - # - - def _get_children_and_consol(cr, uid, ids, level, context={}): - aa_obj = self.pool.get('account.account') - ids2=[] - temp=[] - read_data= aa_obj.read(cr, uid, ids,['id','child_id','level','type'], context) - for data in read_data: - if data['child_id'] and data['level'] < level and data['type']!='consolidation': - ids2.append([data['id'],True, False]) - temp=[] - for x in data['child_id']: - temp.append(x) - ids2 += _get_children_and_consol(cr, uid, temp, level, context) - ids2.append([data['id'],False,True]) - else: - ids2.append([data['id'],True,True]) - return ids2 - - child_ids = _get_children_and_consol(self.cr, self.uid, account_ids, form['display_account_level'] and form['display_account_level'] or 100,self.context) - if child_ids: - account_ids = child_ids - - account_obj = self.pool.get('account.account') - period_obj = self.pool.get('account.period') - fiscalyear_obj = self.pool.get('account.fiscalyear') - - ############################################################################# - # Calculate the period Debit/Credit # - # (from the selected period or all the non special periods in the fy) # - ############################################################################# - - 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)]) - 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']: - ctx['date_from'] = form['date_from'] - ctx['date_to'] = form['date_to'] - - accounts=[] - - val = account_obj.browse(self.cr, self.uid, [aa_id[0] for aa_id in account_ids], ctx) - c = 0 - for aa_id in account_ids: - new_acc = { - 'id' :val[c].id, - 'type' :val[c].type, - 'code' :val[c].code, - 'name' :val[c].name, - 'debit' :val[c].debit, - 'credit' :val[c].credit, - 'parent_id' :val[c].parent_id and val[c].parent_id.id, - 'level' :val[c].level, - 'label' :aa_id[1], - 'total' :aa_id[2], - } - c += 1 - accounts.append(new_acc) - - def missing_period(): - ctx['fiscalyear'] = fiscalyear_obj.search(self.cr, self.uid, [('date_stop','<',fiscalyear.date_start)],order='date_stop') and \ - fiscalyear_obj.search(self.cr, self.uid, [('date_stop','<',fiscalyear.date_start)],order='date_stop')[-1] or [] - ctx['periods'] = period_obj.search(self.cr, self.uid, [('fiscalyear_id','=',ctx['fiscalyear']),('date_stop','<',fiscalyear.date_start)]) - - ############################################################################# - # Calculate the period initial Balance # - # (fy balance minus the balance from the start of the selected period # - # to the end of the year) # - ############################################################################# - - ctx = self.context.copy() - ctx['filter'] = form.get('filter','all') - ctx['fiscalyear'] = fiscalyear.id - - if form['filter'] in ['byperiod', 'all']: - ctx['periods'] = form['periods'] - date_start = min([period.date_start for period in period_obj.browse(self.cr, self.uid, ctx['periods'])]) - ctx['periods'] = period_obj.search(self.cr, self.uid, [('fiscalyear_id','=',fiscalyear.id),('date_stop','<=',date_start)]) - if not ctx['periods']: - missing_period() - elif form['filter'] in ['bydate']: - ctx['date_from'] = fiscalyear.date_start - ctx['date_to'] = form['date_from'] - ctx['periods'] = period_obj.search(self.cr, self.uid, [('fiscalyear_id','=',fiscalyear.id),('date_stop','<=',ctx['date_to'])]) - elif form['filter'] == 'none': - ctx['periods'] = period_obj.search(self.cr, self.uid, [('fiscalyear_id','=',fiscalyear.id),('special','=',True)]) - date_start = min([period.date_start for period in period_obj.browse(self.cr, self.uid, ctx['periods'])]) - ctx['periods'] = period_obj.search(self.cr, self.uid, [('fiscalyear_id','=',fiscalyear.id),('date_start','<=',date_start),('special','=',True)]) - - 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 - - # - # Generate the report lines (checking each account) - # - tot = {} - for account in accounts: - account_id = account['id'] - - accounts_levels[account_id] = account['level'] - - # - # Check if we need to include this level - # - if not form['display_account_level'] or account['level'] <= form['display_account_level']: - # - # Copy the account values - # - res = { - 'id' : account_id, - 'type' : account['type'], - 'code': account['code'], - 'name': (account['total'] and not account['label']) and 'TOTAL %s'%(account['name'].upper()) or account['name'], - 'level': account['level'], - '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'], - 'total': account['total'], - } - # - # Round the values to zero if needed (-0.000001 ~= 0) - # - - if abs(res['balance']) < 0.5 * 10**-4: - res['balance'] = 0.0 - - # - # Check whether we must include this line in the report or not - # - - if form['display_account'] == 'con_movimiento' and account['parent_id']: - # Include accounts with movements - if abs(res['balance']) >= 0.5 * 10**-int(2): - result_acc.append(res) - elif form['display_account'] == 'con_balance' and account['parent_id']: - # Include accounts with balance - if abs(res['balance']) >= 0.5 * 10**-4: - result_acc.append(res) - else: - # 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 tot_check: - str_label = form['lab_str'] - res2 = { - 'type' : 'view', - 'name': 'TOTAL %s'%(str_label), - 'balanceinit': tot_bin, - 'debit': tot_deb, - 'credit': tot_crd, - 'balance': tot_eje, - 'label': False, - 'total': True, - } - result_acc.append(res2) - return result_acc -report_sxw.report_sxw('report.account.account.balance.gene.2', - 'wizard.report.account.balance.gene.2', - 'account_financial_report/report/balance_full_2_cols.rml', - parser=account_balance, - header=False) diff --git a/account_financial_report/report/account_balance_4_cols.py b/account_financial_report/report/account_balance_4_cols.py deleted file mode 100644 index bb6eacaa..00000000 --- a/account_financial_report/report/account_balance_4_cols.py +++ /dev/null @@ -1,377 +0,0 @@ -# -*- encoding: utf-8 -*- -########################################################################### -# Module Writen to OpenERP, Open Source Management Solution -# Copyright (C) OpenERP Venezuela (). -# All Rights Reserved -###############Credits###################################################### -# Coded by: Humberto Arocha humberto@openerp.com.ve -# Angelica Barrios angelicaisabelb@gmail.com -# Jordi Esteve -# Javier Duran -# Planified by: Humberto Arocha -# Finance by: LUBCAN COL S.A.S http://www.lubcancol.com -# Audited by: Humberto Arocha humberto@openerp.com.ve -############################################################################# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU 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 General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . -############################################################################## - -import xml -import copy -from operator import itemgetter -import time -import datetime -from report import report_sxw -from tools import config - - -class account_balance(report_sxw.rml_parse): - - - def __init__(self, cr, uid, name, context): - super(account_balance, self).__init__(cr, uid, name, context) - self.sum_debit = 0.00 - self.sum_credit = 0.00 - self.sum_balance = 0.00 - self.sum_debit_fy = 0.00 - self.sum_credit_fy = 0.00 - self.sum_balance_fy = 0.00 - self.date_lst = [] - self.date_lst_string = '' - self.localcontext.update({ - 'time': time, - 'lines': self.lines, - 'get_fiscalyear_text': self.get_fiscalyear_text, - '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 - - - def get_fiscalyear_text(self, form): - """ - Returns the fiscal year text used on the report. - """ - fiscalyear_obj = self.pool.get('account.fiscalyear') - fiscalyear = None - if form.get('fiscalyear'): - fiscalyear = fiscalyear_obj.browse(self.cr, self.uid, form['fiscalyear']) - return fiscalyear.name or fiscalyear.code - else: - fiscalyear = fiscalyear_obj.browse(self.cr, self.uid, fiscalyear_obj.find(self.cr, self.uid)) - return "%s*" % (fiscalyear.name or fiscalyear.code) - - def get_informe_text(self, form): - """ - Returns the header text used on the report. - """ - inf_type = { - 'bgen' : ' Balance General', - 'bcom' : ' Balance de Comprobacion', - 'edogp': 'Estado de Ganancias y Perdidas', - 'bml': 'Libro Mayor Legal' - } - return inf_type[form['inf_type']] - - def get_month(self, form): - ''' - return day, year and month - ''' - if form['filter'] in ['bydate', 'all']: - months=["Enero","Febrero","Marzo","Abril","Mayo","Junio","Julio","Agosto","Septiembre","Octubre","Noviembre","Diciembre"] - mes = months[time.strptime(form['date_to'],"%Y-%m-%d")[1]-1] - ano = time.strptime(form['date_to'],"%Y-%m-%d")[0] - dia = time.strptime(form['date_to'],"%Y-%m-%d")[2] - return 'Período del '+self.formatLang(form['date_from'], date=True)+' al '+self.formatLang(form['date_to'], date=True) - elif form['filter'] in ['byperiod', 'all']: - aux=[] - period_obj = self.pool.get('account.period') - - for period in period_obj.browse(self.cr, self.uid, form['periods']): - aux.append(period.date_start) - aux.append(period.date_stop) - sorted(aux) - return 'Período del '+self.formatLang(aux[0], date=True)+' al '+self.formatLang(aux[-1], date=True) - - def get_periods_and_date_text(self, form): - """ - Returns the text with the periods/dates used on the report. - """ - period_obj = self.pool.get('account.period') - periods_str = None - fiscalyear_id = form['fiscalyear'] or fiscalyear_obj.find(self.cr, self.uid) - period_ids = period_obj.search(self.cr, self.uid, [('fiscalyear_id','=',fiscalyear_id),('special','=',False)]) - if form['filter'] in ['byperiod', 'all']: - period_ids = form['periods'] - periods_str = ', '.join([period.name or period.code for period in period_obj.browse(self.cr, self.uid, period_ids)]) - - dates_str = None - if form['filter'] in ['bydate', 'all']: - dates_str = self.formatLang(form['date_from'], date=True) + ' - ' + self.formatLang(form['date_to'], date=True) + ' ' - 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 exchange_name(self, form): - 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 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): - 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, 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 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 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 - tot_eje = 0.0 - - if form.has_key('account_list') and form['account_list']: - account_ids = form['account_list'] - del form['account_list'] - res = {} - result_acc = [] - accounts_levels = {} - account_obj = self.pool.get('account.account') - period_obj = self.pool.get('account.period') - fiscalyear_obj = self.pool.get('account.fiscalyear') - - if form.get('fiscalyear'): - 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 - # - - def _get_children_and_consol(cr, uid, ids, level, context={}): - aa_obj = self.pool.get('account.account') - ids2=[] - temp=[] - read_data= aa_obj.read(cr, uid, ids,['id','child_id','level','type'], context) - for data in read_data: - if data['child_id'] and data['level'] < level and data['type']!='consolidation': - ids2.append([data['id'],True, False]) - temp=[] - for x in data['child_id']: - temp.append(x) - ids2 += _get_children_and_consol(cr, uid, temp, level, context) - ids2.append([data['id'],False,True]) - else: - ids2.append([data['id'],True,True]) - return ids2 - - child_ids = _get_children_and_consol(self.cr, self.uid, account_ids, form['display_account_level'] and form['display_account_level'] or 100,self.context) - if child_ids: - account_ids = child_ids - - account_obj = self.pool.get('account.account') - period_obj = self.pool.get('account.period') - fiscalyear_obj = self.pool.get('account.fiscalyear') - - ############################################################################# - # Calculate the period Debit/Credit # - # (from the selected period or all the non special periods in the fy) # - ############################################################################# - - 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)]) - - if ctx['filter'] not in ['bydate','none']: - special = self.special_period(form['periods']) - else: - special = False - - if form['filter'] in ['byperiod', 'all']: - if special: - ctx['periods'] = period_obj.search(self.cr, self.uid, [('id','in',form['periods'] or ctx.get('periods',False))]) - else: - ctx['periods'] = period_obj.search(self.cr, self.uid, [('id','in',form['periods'] or ctx.get('periods',False)),('special','=',False)]) - - if form['filter'] in ['bydate','all','none']: - ctx['date_from'] = form['date_from'] - ctx['date_to'] = form['date_to'] - - accounts=[] - - val = account_obj.browse(self.cr, self.uid, [aa_id[0] for aa_id in account_ids], ctx) - c = 0 - for aa_id in account_ids: - new_acc = { - 'id' :val[c].id, - 'type' :val[c].type, - 'code' :val[c].code, - 'name' :val[c].name, - 'debit' :val[c].debit, - 'credit' :val[c].credit, - 'parent_id' :val[c].parent_id and val[c].parent_id.id, - 'level' :val[c].level, - 'label' :aa_id[1], - 'total' :aa_id[2], - } - c += 1 - accounts.append(new_acc) - - def missing_period(): - ctx['fiscalyear'] = fiscalyear_obj.search(self.cr, self.uid, [('date_stop','<',fiscalyear.date_start)],order='date_stop') and \ - fiscalyear_obj.search(self.cr, self.uid, [('date_stop','<',fiscalyear.date_start)],order='date_stop')[-1] or [] - ctx['periods'] = period_obj.search(self.cr, self.uid, [('fiscalyear_id','=',ctx['fiscalyear']),('date_stop','<',fiscalyear.date_start)]) - - ############################################################################# - # Calculate the period initial Balance # - # (fy balance minus the balance from the start of the selected period # - # to the end of the year) # - ############################################################################# - - ctx = self.context.copy() - ctx['filter'] = form.get('filter','all') - ctx['fiscalyear'] = fiscalyear.id - - if form['filter'] in ['byperiod', 'all']: - ctx['periods'] = form['periods'] - date_start = min([period.date_start for period in period_obj.browse(self.cr, self.uid, ctx['periods'])]) - ctx['periods'] = period_obj.search(self.cr, self.uid, [('fiscalyear_id','=',fiscalyear.id),('date_stop','<=',date_start)]) - if not ctx['periods']: - missing_period() - elif form['filter'] in ['bydate']: - ctx['date_from'] = fiscalyear.date_start - ctx['date_to'] = form['date_from'] - ctx['periods'] = period_obj.search(self.cr, self.uid, [('fiscalyear_id','=',fiscalyear.id),('date_stop','<=',ctx['date_to'])]) - elif form['filter'] == 'none': - ctx['periods'] = period_obj.search(self.cr, self.uid, [('fiscalyear_id','=',fiscalyear.id),('special','=',True)]) - date_start = min([period.date_start for period in period_obj.browse(self.cr, self.uid, ctx['periods'])]) - ctx['periods'] = period_obj.search(self.cr, self.uid, [('fiscalyear_id','=',fiscalyear.id),('date_start','<=',date_start),('special','=',True)]) - - period_balanceinit = {} - for acc in account_obj.browse(self.cr, self.uid, [x[0] for x in account_ids], ctx): - if special: - period_balanceinit[acc['id']] = 0.0 - else: - period_balanceinit[acc['id']] = acc.balance - # - # Generate the report lines (checking each account) - # - tot = {} - for account in accounts: - account_id = account['id'] - - accounts_levels[account_id] = account['level'] - - # - # Check if we need to include this level - # - if not form['display_account_level'] or account['level'] <= form['display_account_level']: - # - # Copy the account values - # - res = { - 'id' : account_id, - 'type' : account['type'], - 'code': account['code'], - 'name': (account['total'] and not account['label']) and 'TOTAL %s'%(account['name'].upper()) or account['name'], - 'level': account['level'], - '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'], - 'total': account['total'], - } - # - # Round the values to zero if needed (-0.000001 ~= 0) - # - - if abs(res['balance']) < 0.5 * 10**-4: - res['balance'] = 0.0 - - # - # Check whether we must include this line in the report or not - # - - if form['display_account'] == 'con_movimiento' and account['parent_id']: - # Include accounts with movements - 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 - if abs(res['balance']) >= 0.5 * 10**-4: - result_acc.append(res) - else: - # 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'] and res['type']=='view' and res['level']==1 and (res['id'] not in tot)): - if tot_check: - str_label = form['lab_str'] - res2 = { - 'type' : 'view', - 'name': 'TOTAL %s'%(str_label), - 'balanceinit': tot_bin, - 'debit': tot_deb, - 'credit': tot_crd, - 'balance': tot_eje, - 'label': False, - 'total': True, - } - result_acc.append(res2) - return result_acc -report_sxw.report_sxw('report.wizard.report.reporte', - 'wizard.report', - 'account_financial_report/report/balance_full_4_cols.rml', - parser=account_balance, - header=False) From de220efa714475e1ae91f56f5158ba6e0bd9100f Mon Sep 17 00:00:00 2001 From: Humberto Arocha Date: Fri, 27 Jul 2012 01:11:59 -0530 Subject: [PATCH 03/49] [IMP] Optimizado Metodo de obtencion de hijos y consolidados --- account_financial_report/report/parser.py | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/account_financial_report/report/parser.py b/account_financial_report/report/parser.py index aa2cbc83..e9054bc6 100644 --- a/account_financial_report/report/parser.py +++ b/account_financial_report/report/parser.py @@ -190,18 +190,13 @@ class account_balance(report_sxw.rml_parse): def _get_children_and_consol(cr, uid, ids, level, context={}): aa_obj = self.pool.get('account.account') ids2=[] - temp=[] - read_data= aa_obj.read(cr, uid, ids,['id','child_id','level','type'], context) - for data in read_data: - if data['child_id'] and data['level'] < level and data['type']!='consolidation': - ids2.append([data['id'],True, False]) - temp=[] - for x in data['child_id']: - temp.append(x) - ids2 += _get_children_and_consol(cr, uid, temp, level, context) - ids2.append([data['id'],False,True]) + for aa_brw in aa_obj.browse(cr, uid, ids, context): + if aa_brw.child_id and aa_brw.level < level and aa_brw.type !='consolidation': + ids2.append([aa_brw.id,True, False]) + ids2 += _get_children_and_consol(cr, uid, [x.id for x in aa_brw.child_id], level, context) + ids2.append([aa_brw.id,False,True]) else: - ids2.append([data['id'],True,True]) + ids2.append([aa_brw.id,True,True]) return ids2 child_ids = _get_children_and_consol(self.cr, self.uid, account_ids, form['display_account_level'] and form['display_account_level'] or 100,self.context) From fdfd8631ab6b7b41fa963e0562dea73a2d1a72c4 Mon Sep 17 00:00:00 2001 From: Humberto Arocha Date: Fri, 27 Jul 2012 01:17:23 -0530 Subject: [PATCH 04/49] [IMP] Se extiende el metodo de consolidacion de cuentas para que cuando el parametro change_sign sea True, devuelva solo una lista de enteros. --- account_financial_report/report/parser.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/account_financial_report/report/parser.py b/account_financial_report/report/parser.py index e9054bc6..881810d6 100644 --- a/account_financial_report/report/parser.py +++ b/account_financial_report/report/parser.py @@ -187,16 +187,16 @@ class account_balance(report_sxw.rml_parse): # Get the accounts # - def _get_children_and_consol(cr, uid, ids, level, context={}): + def _get_children_and_consol(cr, uid, ids, level, context={},change_sign=False): aa_obj = self.pool.get('account.account') ids2=[] for aa_brw in aa_obj.browse(cr, uid, ids, context): if aa_brw.child_id and aa_brw.level < level and aa_brw.type !='consolidation': - ids2.append([aa_brw.id,True, False]) + change_sign or ids2.append([aa_brw.id,True, False]) ids2 += _get_children_and_consol(cr, uid, [x.id for x in aa_brw.child_id], level, context) - ids2.append([aa_brw.id,False,True]) + change_sign and ids2.append(aa_brw.id) or ids2.append([aa_brw.id,False,True]) else: - ids2.append([aa_brw.id,True,True]) + change_sign and ids2.append(aa_brw.id) or ids2.append([aa_brw.id,True,True]) return ids2 child_ids = _get_children_and_consol(self.cr, self.uid, account_ids, form['display_account_level'] and form['display_account_level'] or 100,self.context) From c687bd818377a186450f431f09f54661f1cff7b4 Mon Sep 17 00:00:00 2001 From: Humberto Arocha Date: Fri, 27 Jul 2012 01:18:24 -0530 Subject: [PATCH 05/49] [IMP] Eliminacion de Asignacion innecesaria --- account_financial_report/report/parser.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/account_financial_report/report/parser.py b/account_financial_report/report/parser.py index 881810d6..963ae8d0 100644 --- a/account_financial_report/report/parser.py +++ b/account_financial_report/report/parser.py @@ -199,9 +199,7 @@ class account_balance(report_sxw.rml_parse): change_sign and ids2.append(aa_brw.id) or ids2.append([aa_brw.id,True,True]) return ids2 - child_ids = _get_children_and_consol(self.cr, self.uid, account_ids, form['display_account_level'] and form['display_account_level'] or 100,self.context) - if child_ids: - account_ids = child_ids + account_ids = _get_children_and_consol(self.cr, self.uid, account_ids, form['display_account_level'] and form['display_account_level'] or 100,self.context) account_obj = self.pool.get('account.account') period_obj = self.pool.get('account.period') From 417ff99db2c37815c4e041fe55464581a493e9d0 Mon Sep 17 00:00:00 2001 From: Humberto Arocha Date: Fri, 27 Jul 2012 01:38:48 -0530 Subject: [PATCH 06/49] [FIX] Se afina metodo de consolidacion de cuentas --- account_financial_report/report/parser.py | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/account_financial_report/report/parser.py b/account_financial_report/report/parser.py index 963ae8d0..b25f244a 100644 --- a/account_financial_report/report/parser.py +++ b/account_financial_report/report/parser.py @@ -169,6 +169,7 @@ class account_balance(report_sxw.rml_parse): if form.has_key('account_list') and form['account_list']: account_ids = form['account_list'] del form['account_list'] + credit_account_ids = account_ids res = {} result_acc = [] accounts_levels = {} @@ -192,15 +193,26 @@ class account_balance(report_sxw.rml_parse): ids2=[] for aa_brw in aa_obj.browse(cr, uid, ids, context): if aa_brw.child_id and aa_brw.level < level and aa_brw.type !='consolidation': - change_sign or ids2.append([aa_brw.id,True, False]) - ids2 += _get_children_and_consol(cr, uid, [x.id for x in aa_brw.child_id], level, context) - change_sign and ids2.append(aa_brw.id) or ids2.append([aa_brw.id,False,True]) + if not change_sign: + ids2.append([aa_brw.id,True, False]) + ids2 += _get_children_and_consol(cr, uid, [x.id for x in aa_brw.child_id], level, context,change_sign=change_sign) + if change_sign: + ids2.append(aa_brw.id) + else: + ids2.append([aa_brw.id,False,True]) else: - change_sign and ids2.append(aa_brw.id) or ids2.append([aa_brw.id,True,True]) + if change_sign: + ids2.append(aa_brw.id) + else: + ids2.append([aa_brw.id,True,True]) return ids2 account_ids = _get_children_and_consol(self.cr, self.uid, account_ids, form['display_account_level'] and form['display_account_level'] or 100,self.context) + credit_account_ids = _get_children_and_consol(self.cr, self.uid, credit_account_ids, 100,self.context,change_sign=True) + + print 'credit_account_ids ', credit_account_ids + account_obj = self.pool.get('account.account') period_obj = self.pool.get('account.period') fiscalyear_obj = self.pool.get('account.fiscalyear') From 58ab2bb141aa360b995c8081381d1363deab46fa Mon Sep 17 00:00:00 2001 From: Humberto Arocha Date: Fri, 27 Jul 2012 02:23:59 -0530 Subject: [PATCH 07/49] [ADD] Se agrega campo de cuentas de naturaleza acreditable a la compania para que permite mostrar adecuadamente los signos en los reportes contables. --- account_financial_report/__init__.py | 1 + account_financial_report/__openerp__.py | 7 ++-- account_financial_report/model/__init__.py | 26 +++++++++++++ account_financial_report/model/res_company.py | 38 +++++++++++++++++++ .../view/company_view.xml | 26 +++++++++++++ 5 files changed, 95 insertions(+), 3 deletions(-) create mode 100755 account_financial_report/model/__init__.py create mode 100755 account_financial_report/model/res_company.py create mode 100644 account_financial_report/view/company_view.xml diff --git a/account_financial_report/__init__.py b/account_financial_report/__init__.py index 14c22fdf..64829f5d 100644 --- a/account_financial_report/__init__.py +++ b/account_financial_report/__init__.py @@ -25,5 +25,6 @@ # along with this program. If not, see . ############################################################################## +import model import report import wizard diff --git a/account_financial_report/__openerp__.py b/account_financial_report/__openerp__.py index 5937b790..77dbffa3 100644 --- a/account_financial_report/__openerp__.py +++ b/account_financial_report/__openerp__.py @@ -26,9 +26,9 @@ ############################################################################## { "name" : "Common financial reports", - "version" : "1.0", - "author" : "OpenERP Venezuela", - "website" : "http://wiki.openerp.org.ve/", + "version" : "2.0", + "author" : "Vauxoo", + "website" : "http://www.vauxoo.com", "depends" : ["base","account"], "category" : "Localisation/Accounting", "description": """ @@ -40,6 +40,7 @@ "wizard/wizard_report_report.xml", "wizard/account_report_wizard.xml", "view/account_view.xml", + "view/company_view.xml", ], "active": False, "installable": True diff --git a/account_financial_report/model/__init__.py b/account_financial_report/model/__init__.py new file mode 100755 index 00000000..48c4ca46 --- /dev/null +++ b/account_financial_report/model/__init__.py @@ -0,0 +1,26 @@ +#!/usr/bin/python +# -*- encoding: utf-8 -*- +########################################################################### +# Module Writen to OpenERP, Open Source Management Solution +# Copyright (C) OpenERP Venezuela (). +# All Rights Reserved +###############Credits###################################################### +# Coded by: Humberto Arocha +# Planified by: Rafael Silva +# Audited by: Nhomar Hernandez +############################################################################# +# 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 res_company diff --git a/account_financial_report/model/res_company.py b/account_financial_report/model/res_company.py new file mode 100755 index 00000000..2bbb383d --- /dev/null +++ b/account_financial_report/model/res_company.py @@ -0,0 +1,38 @@ +#!/usr/bin/python +# -*- encoding: utf-8 -*- +########################################################################### +# Module Writen to OpenERP, Open Source Management Solution +# Copyright (C) OpenERP Venezuela (). +# All Rights Reserved +###############Credits###################################################### +# Coded by: Humberto Arocha +# Planified by: Rafael Silva +# Audited by: Nhomar Hernandez +############################################################################# +# 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 . +################################################################################ + +from osv import osv +from osv import fields +from tools.translate import _ + +class res_company(osv.osv): + _inherit = 'res.company' + _columns = { + 'credit_account_ids':fields.many2many('account.account', + 'credit_account_company_rel', + 'company_id', 'account_id', + 'Accounts'), + } +res_company() diff --git a/account_financial_report/view/company_view.xml b/account_financial_report/view/company_view.xml new file mode 100644 index 00000000..08f830e0 --- /dev/null +++ b/account_financial_report/view/company_view.xml @@ -0,0 +1,26 @@ + + + + + res.company.form.inherit + + res.company + form + + + + + + + + + + + + + + + + + + From e79353e08a2944dcc9080ec33637c3f88128a350 Mon Sep 17 00:00:00 2001 From: Humberto Arocha Date: Fri, 27 Jul 2012 02:53:27 -0530 Subject: [PATCH 08/49] [IMP] Ahora El signo del reporte se muestra de acuerdo a la naturaleza de la cuenta --- .../report/balance_full_4_cols.rml | 4 ++-- account_financial_report/report/parser.py | 11 ++++++++++- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/account_financial_report/report/balance_full_4_cols.rml b/account_financial_report/report/balance_full_4_cols.rml index 1004de65..24e99016 100644 --- a/account_financial_report/report/balance_full_4_cols.rml +++ b/account_financial_report/report/balance_full_4_cols.rml @@ -122,7 +122,7 @@ [[ a['type']<>'view' and setTag('para','para',{'fontName':"Courier"}) or removeParentNode('font') ]] - [[ (a['total']==True) and formatLang(a['balanceinit'], digits=2, grouping=True) or '']] + [[ (a['total']==True) and formatLang(a['balanceinit'] and a['balanceinit'] * a.get('change_sign') or 0.0, digits=2, grouping=True) or '']] @@ -140,7 +140,7 @@ [[ a['type']<>'view' and setTag('para','para',{'fontName':"Courier"}) or removeParentNode('font') ]] - [[ (a['total']==True) and formatLang(a['balance'], digits=2, grouping=True) or '']] + [[ (a['total']==True) and formatLang(a['balance'] and a['balance'] * a.get('change_sign') or 0.0, digits=2, grouping=True) or '']] diff --git a/account_financial_report/report/parser.py b/account_financial_report/report/parser.py index b25f244a..e8c1e42b 100644 --- a/account_financial_report/report/parser.py +++ b/account_financial_report/report/parser.py @@ -149,6 +149,10 @@ 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 get_company_credit_accounts(self, company_id): + rc_obj = self.pool.get('res.company') + return [brw.id for brw in rc_obj.browse(self.cr, self.uid, company_id).credit_account_ids] + def lines(self, form, level=0): """ Returns all the data needed for the report lines @@ -169,7 +173,11 @@ class account_balance(report_sxw.rml_parse): if form.has_key('account_list') and form['account_list']: account_ids = form['account_list'] del form['account_list'] - credit_account_ids = account_ids + + credit_account_ids = self.get_company_credit_accounts(form['company_id'] and type(form['company_id']) in (list,tuple) and form['company_id'][0] or form['company_id']) + + print 'Primer print de credit_account_ids ', credit_account_ids + res = {} result_acc = [] accounts_levels = {} @@ -328,6 +336,7 @@ class account_balance(report_sxw.rml_parse): 'bal_type': '', 'label': account['label'], 'total': account['total'], + 'change_sign' : credit_account_ids and (account_id in credit_account_ids and -1 or 1) or 1 } # # Round the values to zero if needed (-0.000001 ~= 0) From 827d6dd95da0e2ada9a7ff44d0cbdb0d9fbb237a Mon Sep 17 00:00:00 2001 From: Humberto Arocha Date: Fri, 27 Jul 2012 09:22:55 -0530 Subject: [PATCH 09/49] [IMP] Se hace al reporte de una columna sensible al cambio de signo en las cuentas acreditables --- account_financial_report/report/balance_full.rml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/account_financial_report/report/balance_full.rml b/account_financial_report/report/balance_full.rml index 83513f0f..d4c773e2 100644 --- a/account_financial_report/report/balance_full.rml +++ b/account_financial_report/report/balance_full.rml @@ -116,7 +116,7 @@ [[ a['type']<>'view' and setTag('para','para',{'fontName':"Courier"}) or removeParentNode('font') ]] - [[(a['total']==True) and formatLang(a['balance']) or '']] + [[ (a['total']==True) and formatLang(a['balance'] and a['balance'] * a.get('change_sign') or 0.0, digits=2, grouping=True) or '']] From 67a6556955ce061f5ac055dc70589226f668fbd6 Mon Sep 17 00:00:00 2001 From: Humberto Arocha Date: Fri, 27 Jul 2012 17:33:42 -0530 Subject: [PATCH 10/49] [IMP] Se une en un solo Wizard todos los reportes --- account_financial_report/__openerp__.py | 4 +- .../report/account_report_report.xml | 42 ++--- account_financial_report/report/parser.py | 15 +- .../report.xml} | 28 +-- account_financial_report/view/wizard.xml | 94 ++++++++++ account_financial_report/wizard/__init__.py | 6 +- account_financial_report/wizard/wizard.py | 162 ++++++++++++++++++ 7 files changed, 303 insertions(+), 48 deletions(-) rename account_financial_report/{wizard/wizard_report_report.xml => view/report.xml} (68%) create mode 100644 account_financial_report/view/wizard.xml create mode 100644 account_financial_report/wizard/wizard.py diff --git a/account_financial_report/__openerp__.py b/account_financial_report/__openerp__.py index 77dbffa3..2430be9e 100644 --- a/account_financial_report/__openerp__.py +++ b/account_financial_report/__openerp__.py @@ -37,8 +37,8 @@ "demo_xml" : [], "update_xml" : [ "security/security.xml", - "wizard/wizard_report_report.xml", - "wizard/account_report_wizard.xml", + "view/report.xml", + "view/wizard.xml", "view/account_view.xml", "view/company_view.xml", ], diff --git a/account_financial_report/report/account_report_report.xml b/account_financial_report/report/account_report_report.xml index 6ce7e71b..37f26d48 100644 --- a/account_financial_report/report/account_report_report.xml +++ b/account_financial_report/report/account_report_report.xml @@ -1,33 +1,35 @@ - - + - + + id="wizard_report_reporte" + menu="True" + model="wizard.report.account.balance.gene" + name="account.account.balance.gene" + rml="account_financial_report/report/balance_full.rml" + string="Balance de Comprobacion Wizard" + header="False" + /> - diff --git a/account_financial_report/report/parser.py b/account_financial_report/report/parser.py index e8c1e42b..b6bb5873 100644 --- a/account_financial_report/report/parser.py +++ b/account_financial_report/report/parser.py @@ -384,21 +384,20 @@ class account_balance(report_sxw.rml_parse): result_acc.append(res2) return result_acc - -report_sxw.report_sxw('report.wizard.report.reporte', +report_sxw.report_sxw('report.afr.1cols', 'wizard.report', - 'account_financial_report/report/balance_full_4_cols.rml', + 'account_financial_report/report/balance_full.rml', parser=account_balance, header=False) -report_sxw.report_sxw('report.account.account.balance.gene.2', - 'wizard.report.account.balance.gene.2', +report_sxw.report_sxw('report.afr.2cols', + 'wizard.report', 'account_financial_report/report/balance_full_2_cols.rml', parser=account_balance, header=False) -report_sxw.report_sxw('report.account.account.balance.gene', - 'wizard.report.account.balance.gene', - 'account_financial_report/report/balance_full.rml', +report_sxw.report_sxw('report.afr.4cols', + 'wizard.report', + 'account_financial_report/report/balance_full_4_cols.rml', parser=account_balance, header=False) diff --git a/account_financial_report/wizard/wizard_report_report.xml b/account_financial_report/view/report.xml similarity index 68% rename from account_financial_report/wizard/wizard_report_report.xml rename to account_financial_report/view/report.xml index d9d4cb9f..983185fe 100644 --- a/account_financial_report/wizard/wizard_report_report.xml +++ b/account_financial_report/view/report.xml @@ -1,36 +1,38 @@ + + + - diff --git a/account_financial_report/view/wizard.xml b/account_financial_report/view/wizard.xml new file mode 100644 index 00000000..ed3a8b3a --- /dev/null +++ b/account_financial_report/view/wizard.xml @@ -0,0 +1,94 @@ + + + + + + Wizard Report Balance Four Columns + wizard.report + form + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +