Browse Source

[MERGE] Se mezcla nueva iteracion del asistente


			
			
				6.0
			
			
		
Humberto Arocha 12 years ago
parent
commit
b15741b877
  1. 1
      account_financial_report/__init__.py
  2. 20
      account_financial_report/__openerp__.py
  3. 1120
      account_financial_report/i18n/account_financial_report.pot
  4. 1154
      account_financial_report/i18n/ca.po
  5. 1139
      account_financial_report/i18n/ca_ES.po
  6. BIN
      account_financial_report/i18n/es.mo
  7. 1316
      account_financial_report/i18n/es.po
  8. 1132
      account_financial_report/i18n/es_ES.po
  9. 1149
      account_financial_report/i18n/pl.po
  10. 27
      account_financial_report/model/__init__.py
  11. 133
      account_financial_report/model/account_financial_report.py
  12. 42
      account_financial_report/model/res_company.py
  13. 4
      account_financial_report/report/__init__.py
  14. 334
      account_financial_report/report/account_balance.py
  15. 360
      account_financial_report/report/account_balance_2_cols.py
  16. 377
      account_financial_report/report/account_balance_4_cols.py
  17. 33
      account_financial_report/report/account_report_report.xml
  18. 15
      account_financial_report/report/balance_full.rml
  19. 230
      account_financial_report/report/balance_full_13_cols.rml
  20. 15
      account_financial_report/report/balance_full_2_cols.rml
  21. 20
      account_financial_report/report/balance_full_4_cols.rml
  22. 294
      account_financial_report/report/balance_full_4_cols_analytic_ledger.rml
  23. 158
      account_financial_report/report/balance_full_5_cols.rml
  24. 158
      account_financial_report/report/balance_full_qtr_cols.rml
  25. 737
      account_financial_report/report/parser.py
  26. 157
      account_financial_report/view/account_financial_report_view.xml
  27. 47
      account_financial_report/view/company_view.xml
  28. 82
      account_financial_report/view/report.xml
  29. 129
      account_financial_report/view/wizard.xml
  30. 6
      account_financial_report/wizard/__init__.py
  31. 209
      account_financial_report/wizard/account_report_wizard.xml
  32. 258
      account_financial_report/wizard/wizard.py
  33. 150
      account_financial_report/wizard/wizard_account_balance_2_report.py
  34. 150
      account_financial_report/wizard/wizard_account_balance_4_report.py
  35. 150
      account_financial_report/wizard/wizard_account_balance_report.py
  36. 36
      account_financial_report/wizard/wizard_report_report.xml

1
account_financial_report/__init__.py

@ -25,5 +25,6 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>. # along with this program. If not, see <http://www.gnu.org/licenses/>.
############################################################################## ##############################################################################
import model
import report import report
import wizard import wizard

20
account_financial_report/__openerp__.py

@ -26,20 +26,28 @@
############################################################################## ##############################################################################
{ {
"name" : "Common financial reports", "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"], "depends" : ["base","account"],
"category" : "Localisation/Accounting", "category" : "Localisation/Accounting",
"description": """ "description": """
""",
This modules is a multiporpuse report generator.
From the wizard you will be asked to provide information needed to create your report.
Not only you can set the option within the wizard you can create your own Customized Account Financial Reports, in here, you will be able to create Templates for generating Two types of Reports: Balance Sheets and Income Statements, incluiding Analytic Ledgers. Besides, you can select within a set of choices to get better detailed report, be it that you ask it by one or several periods, by months (12 Months + YTD), or by quarters (4QRT's + YTD). Even you can get your reports in currencies other than the one set on your company.
In the [ Account's Sign on Reports ] Section in the Company will be able to set the sign conventions for the Accounts, so that you will be able to see in positives Values in your reports for those accounts with Accreditable nature where appropriate""",
"init_xml" : [], "init_xml" : [],
"demo_xml" : [], "demo_xml" : [],
"update_xml" : [ "update_xml" : [
"security/security.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/account_view.xml",
"view/company_view.xml",
"view/account_financial_report_view.xml",
], ],
"active": False, "active": False,
"installable": True "installable": True

1120
account_financial_report/i18n/account_financial_report.pot
File diff suppressed because it is too large
View File

1154
account_financial_report/i18n/ca.po
File diff suppressed because it is too large
View File

1139
account_financial_report/i18n/ca_ES.po
File diff suppressed because it is too large
View File

BIN
account_financial_report/i18n/es.mo

1316
account_financial_report/i18n/es.po
File diff suppressed because it is too large
View File

1132
account_financial_report/i18n/es_ES.po
File diff suppressed because it is too large
View File

1149
account_financial_report/i18n/pl.po
File diff suppressed because it is too large
View File

27
account_financial_report/model/__init__.py

@ -0,0 +1,27 @@
#!/usr/bin/python
# -*- encoding: utf-8 -*-
###########################################################################
# Module Writen to OpenERP, Open Source Management Solution
# Copyright (C) OpenERP Venezuela (<http://openerp.com.ve>).
# All Rights Reserved
###############Credits######################################################
# Coded by: Humberto Arocha <hbto@vauxoo.com>
# Planified by: Rafael Silva <rsilvam@vauxoo.com>
# Audited by: Nhomar Hernandez <nhomar@vauxoo.com>
#############################################################################
# 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 <http://www.gnu.org/licenses/>.
################################################################################
import account_financial_report
import res_company

133
account_financial_report/model/account_financial_report.py

@ -0,0 +1,133 @@
# -*- encoding: utf-8 -*-
###########################################################################
# Module Writen to OpenERP, Open Source Management Solution
# Copyright (C) OpenERP Venezuela (<http://openerp.com.ve>).
# All Rights Reserved
###############Credits######################################################
# Coded by: Humberto Arocha humberto@openerp.com.ve
# Angelica Barrios angelicaisabelb@gmail.com
# Jordi Esteve <jesteve@zikzakmedia.com>
# Javier Duran <javieredm@gmail.com>
# 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 <http://www.gnu.org/licenses/>.
##############################################################################
from osv import osv,fields
import pooler
import time
from tools.translate import _
class account_financial_report(osv.osv):
_name = "afr"
_columns = {
'name': fields.char('Name', size= 128, required=True),
'company_id': fields.many2one('res.company','Company',required=True),
'currency_id': fields.many2one('res.currency', 'Currency', help="Currency at which this report will be expressed. If not selected will be used the one set in the company"),
'inf_type': fields.selection([('BS','Balance Sheet'),('IS','Income Statement')],'Type',required=True),
'columns': fields.selection([('one','End. Balance'),('two','Debit | Credit'), ('four','Initial | Debit | Credit | YTD'), ('five','Initial | Debit | Credit | Period | YTD'),('qtr',"4 QTR's | YTD"), ('thirteen','12 Months | YTD')],'Columns',required=True),
'display_account': fields.selection([('all','All Accounts'),('bal', 'With Balance'),('mov','With movements'),('bal_mov','With Balance / Movements')],'Display accounts'),
'display_account_level': fields.integer('Up to level',help='Display accounts up to this level (0 to show all)'),
'account_ids': fields.many2many ('account.account','afr_account_rel','afr_id','account_id','Root accounts',required=True),
'fiscalyear_id': fields.many2one('account.fiscalyear','Fiscal year',help='Fiscal Year for this report',required=True),
'period_ids': fields.many2many('account.period','afr_period_rel','afr_id','period_id','Periods',help='All periods in the fiscal year if empty'),
'analytic_ledger': fields.boolean('Analytic Ledger', help="Allows to Generate an Analytic Ledger for accounts with moves. Available when Balance Sheet and 'Initial | Debit | Credit | YTD' are selected"),
'tot_check': fields.boolean('Summarize?', help='Checking will add a new line at the end of the Report which will Summarize Columns in Report'),
'lab_str': fields.char('Description', help='Description for the Summary', size= 128),
#~ Deprecated fields
'filter': fields.selection([('bydate','By Date'),('byperiod','By Period'),('all','By Date and Period'),('none','No Filter')],'Date/Period Filter'),
'date_to': fields.date('End date'),
'date_from': fields.date('Start date'),
}
_defaults = {
'display_account_level': lambda *a: 0,
'inf_type': lambda *a:'BS',
'company_id': lambda self,cr,uid,c: self.pool.get('res.company')._company_default_get(cr, uid, 'account.invoice', context=c),
'fiscalyear_id': lambda self, cr, uid, c: self.pool.get('account.fiscalyear').find(cr, uid),
'display_account': lambda *a:'bal_mov',
'columns': lambda *a:'five',
'date_from': lambda *a: time.strftime('%Y-%m-%d'),
'date_to': lambda *a: time.strftime('%Y-%m-%d'),
'filter': lambda *a:'byperiod',
}
def copy(self, cr, uid, id, defaults, context=None):
if context is None:
context = {}
previous_name = self.browse(cr, uid, id, context=context).name
new_name = _('Copy of %s')%previous_name
lst = self.search(cr, uid, [('name','like',new_name)], context=context)
if lst:
new_name = '%s (%s)' % (new_name, len(lst)+1)
defaults['name'] = new_name
return super(account_financial_report,self).copy(cr, uid, id, defaults, context=context)
def onchange_inf_type(self,cr,uid,ids,inf_type,context=None):
if context is None:
context = {}
res = {'value':{}}
if inf_type != 'BS':
res['value'].update({'analytic_ledger':False})
return res
def onchange_columns(self,cr,uid,ids,columns,fiscalyear_id,period_ids,context=None):
if context is None:
context = {}
res = {'value':{}}
if columns != 'four':
res['value'].update({'analytic_ledger':False})
if columns in ('qtr', 'thirteen'):
p_obj = self.pool.get("account.period")
period_ids = p_obj.search(cr,uid,[('fiscalyear_id','=',fiscalyear_id),('special','=',False)],context=context)
res['value'].update({'period_ids':period_ids})
else:
res['value'].update({'period_ids':[]})
return res
def onchange_analytic_ledger(self,cr,uid,ids,company_id,analytic_ledger,context=None):
if context is None:
context = {}
context['company_id']=company_id
res = {'value':{}}
cur_id = self.pool.get('res.company').browse(cr,uid,company_id,context=context).currency_id.id
res['value'].update({'currency_id':cur_id})
return res
def onchange_company_id(self,cr,uid,ids,company_id,context=None):
if context is None:
context = {}
context['company_id']=company_id
res = {'value':{}}
cur_id = self.pool.get('res.company').browse(cr,uid,company_id,context=context).currency_id.id
fy_id = self.pool.get('account.fiscalyear').find(cr, uid,context=context)
res['value'].update({'fiscalyear_id':fy_id})
res['value'].update({'currency_id':cur_id})
res['value'].update({'account_ids':[]})
res['value'].update({'period_ids':[]})
return res
account_financial_report()

42
account_financial_report/model/res_company.py

@ -0,0 +1,42 @@
#!/usr/bin/python
# -*- encoding: utf-8 -*-
###########################################################################
# Module Writen to OpenERP, Open Source Management Solution
# Copyright (C) OpenERP Venezuela (<http://openerp.com.ve>).
# All Rights Reserved
###############Credits######################################################
# Coded by: Humberto Arocha <hbto@vauxoo.com>
# Planified by: Rafael Silva <rsilvam@vauxoo.com>
# Audited by: Nhomar Hernandez <nhomar@vauxoo.com>
#############################################################################
# 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 <http://www.gnu.org/licenses/>.
################################################################################
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',
'Creditable Accounts'),
'debit_account_ids':fields.many2many('account.account',
'debit_account_company_rel',
'company_id', 'account_id',
'Debitable Accounts'),
}
res_company()

4
account_financial_report/report/__init__.py

@ -25,6 +25,4 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>. # along with this program. If not, see <http://www.gnu.org/licenses/>.
############################################################################## ##############################################################################
import account_balance
import account_balance_4_cols
import account_balance_2_cols
import parser

334
account_financial_report/report/account_balance.py

@ -1,334 +0,0 @@
# -*- encoding: utf-8 -*-
###########################################################################
# Module Writen to OpenERP, Open Source Management Solution
# Copyright (C) OpenERP Venezuela (<http://openerp.com.ve>).
# All Rights Reserved
###############Credits######################################################
# Coded by: Humberto Arocha humberto@openerp.com.ve
# Angelica Barrios angelicaisabelb@gmail.com
# Jordi Esteve <jesteve@zikzakmedia.com>
# Javier Duran <javieredm@gmail.com>
# 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 <http://www.gnu.org/licenses/>.
##############################################################################
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)

360
account_financial_report/report/account_balance_2_cols.py

@ -1,360 +0,0 @@
# -*- encoding: utf-8 -*-
###########################################################################
# Module Writen to OpenERP, Open Source Management Solution
# Copyright (C) OpenERP Venezuela (<http://openerp.com.ve>).
# All Rights Reserved
###############Credits######################################################
# Coded by: Humberto Arocha humberto@openerp.com.ve
# Angelica Barrios angelicaisabelb@gmail.com
# Jordi Esteve <jesteve@zikzakmedia.com>
# Javier Duran <javieredm@gmail.com>
# 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 <http://www.gnu.org/licenses/>.
##############################################################################
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)

377
account_financial_report/report/account_balance_4_cols.py

@ -1,377 +0,0 @@
# -*- encoding: utf-8 -*-
###########################################################################
# Module Writen to OpenERP, Open Source Management Solution
# Copyright (C) OpenERP Venezuela (<http://openerp.com.ve>).
# All Rights Reserved
###############Credits######################################################
# Coded by: Humberto Arocha humberto@openerp.com.ve
# Angelica Barrios angelicaisabelb@gmail.com
# Jordi Esteve <jesteve@zikzakmedia.com>
# Javier Duran <javieredm@gmail.com>
# 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 <http://www.gnu.org/licenses/>.
##############################################################################
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)

33
account_financial_report/report/account_report_report.xml

@ -1,33 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<openerp>
<data >
<report
id="account_balance_full"
string="General account balance"
model="account.account"
name="account.account.balance.gene"
rml="account_financial_report/report/balance_full.rml"
header="False"
auto="False"
menu="False"/>
<report
id="account_balance_full_4_cols"
string="General account balance Four Columns"
model="account.account"
name="account.account.balance.gene.4"
rml="account_financial_report/report/balance_full_4_cols.rml"
header="False"
auto="False"
menu="False"/>
<report
id="account_balance_full_2_cols"
string="General account balance Two Columns"
model="account.account"
name="account.account.balance.gene.2"
rml="account_financial_report/report/balance_full_2_cols.rml"
header="False"
auto="False"
menu="False"/>
</data>
</openerp>

15
account_financial_report/report/balance_full.rml

@ -5,6 +5,11 @@
<frame id="first" x1="1cm" y1="1.0cm" width="19.0cm" height="23cm"/> <frame id="first" x1="1cm" y1="1.0cm" width="19.0cm" height="23cm"/>
<pageGraphics> <pageGraphics>
<setFont name="Helvetica" size="9"/> <setFont name="Helvetica" size="9"/>
<image x="1.0cm" y="24.0cm" width="5.0cm">[[company.logo and company.logo or removeParentNode('image')]]</image>
<!--
<drawString x="1.0cm" y="24.5cm">[[company.logo and removeParentNode('para') or company.name]]</drawString>
-->
<place x="-3.5cm" y="22.50cm" width="19cm" height="5.0cm"> <place x="-3.5cm" y="22.50cm" width="19cm" height="5.0cm">
<blockTable colWidths="9.6cm,9.4cm" style="TITLE"> <blockTable colWidths="9.6cm,9.4cm" style="TITLE">
<tr> <tr>
@ -16,7 +21,7 @@
</tr> </tr>
<tr> <tr>
<td><para style="TOP_TITLE"></para></td> <td><para style="TOP_TITLE"></para></td>
<td><para style="TITLE_CENTER">[[data['form'] and (' (Expresado en %s)'%( exchange_name(data['form']))) or '']]</para></td>
<td><para style="TITLE_CENTER">[[data['form'] and (' (Expressed in %s)'%( exchange_name(data['form']))) or '']]</para></td>
</tr> </tr>
<tr> <tr>
<td><para style="TOP_TITLE"></para></td> <td><para style="TOP_TITLE"></para></td>
@ -90,14 +95,14 @@
<td> <td>
<para style="TITLE_LEFT_ALIGN"> <para style="TITLE_LEFT_ALIGN">
<font>[[ setTag('para','para',{'alignment':"RIGHT"}) ]]</font> <font>[[ setTag('para','para',{'alignment':"RIGHT"}) ]]</font>
<font>Código</font>
<font>CODE</font>
</para> </para>
</td> </td>
<td> <td>
<para style="TITLES">Cuenta</para>
<para style="TITLES">ACCOUNT</para>
</td> </td>
<td> <td>
<para style="TITLE_LEFT_ALIGN">Balance</para>
<para style="TITLE_LEFT_ALIGN">BALANCE</para>
</td> </td>
</tr> </tr>
<tr> <tr>
@ -116,7 +121,7 @@
<td> <td>
<para style="TITLE_LEFT_ALIGN"> <para style="TITLE_LEFT_ALIGN">
<font>[[ a['type']&lt;&gt;'view' and setTag('para','para',{'fontName':"Courier"}) or removeParentNode('font') ]]</font> <font>[[ a['type']&lt;&gt;'view' and setTag('para','para',{'fontName':"Courier"}) or removeParentNode('font') ]]</font>
<font>[[(a['total']==True) and formatLang(a['balance']) or '']]</font>
<font>[[ (a['total']==True) and formatLang(a['balance'] and a['balance'] * a.get('change_sign') or 0.0, digits=2, grouping=True) or '']]</font>
</para> </para>
</td> </td>
</tr> </tr>

230
account_financial_report/report/balance_full_13_cols.rml

@ -0,0 +1,230 @@
<?xml version="1.0"?>
<document filename="test.pdf">
<template pageSize="(43.18cm,27.94cm)" title="Test" author="Martin Simon" allowSplitting="20" showBoundary="0">
<pageTemplate id="first">
<frame id="first" x1="0.5cm" y1="1.0cm" width="41.0cm" height="23cm"/>
<pageGraphics>
<setFont name="Helvetica" size="9"/>
<image x="1.0cm" y="24.0cm" width="5.0cm">[[company.logo and company.logo or removeParentNode('image')]]</image>
<!--
<drawString x="1.0cm" y="24.5cm">[[company.logo and removeParentNode('para') or company.name]]</drawString>
-->
<place x="-3.5cm" y="22.50cm" width="19cm" height="5.0cm">
<blockTable colWidths="9.6cm,9.4cm" style="TITLE">
<tr>
<td><para style="TOP_TITLE"></para></td>
<td><para style="TITLE_CENTER_NAME">
<font>[[ (company.name and company.name or 'NOMBRE DE COMPANIA NO DISPONIBLE')]]</font>
<font>[[ company.partner_id.vat and ('- %s-%s-%s'%(company.partner_id.vat[2:3],company.partner_id.vat[3:11],company.partner_id.vat[11:12])) or '' ]]</font>
</para></td>
</tr>
<tr>
<td><para style="TOP_TITLE"></para></td>
<td><para style="TITLE_CENTER">[[ get_informe_text(data['form']) ]]</para></td>
</tr>
<tr>
<td><para style="TOP_TITLE"></para></td>
<td><para style="TITLE_CENTER">[[data['form'] and (' (Expressed in %s)'%( exchange_name(data['form']))) or '']]</para></td>
</tr>
<tr>
<td><para style="TOP_TITLE"></para></td>
<td><para style="TITLE_CENTER">[[data['form'] and get_month(data['form']) or '']]</para></td>
</tr>
</blockTable>
</place>
<drawRightString x="192mm" y="5mm">[[ get_informe_text(data['form']) ]] / Pág.: <pageNumber/>-<pageCount/> </drawRightString>
</pageGraphics>
</pageTemplate>
</template>
<stylesheet>
<blockTableStyle id="TITLE">
<blockValign value="TOP"/>
</blockTableStyle>
<blockTableStyle id="BODY">
<blockValign value="TOP"/>
<blockAlignment value="RIGHT"/>
<blockTopPadding length="1.0"/>
<blockBottomPadding length="1.0"/>
<lineStyle kind="LINEBELOW" colorName="#e6e6e6" start="0,1" stop="-1,-1" thickness='0.25'/>
</blockTableStyle>
<blockTableStyle id="BODY_STRIKE">
<blockValign value="TOP"/>
<blockAlignment value="RIGHT"/>
<blockTopPadding length="1.0"/>
<blockBottomPadding length="1.0"/>
<lineStyle kind="LINEBELOW" colorName="#FFFFFF" start="0,1" stop="-1,-1" thickness='0.5'/>
</blockTableStyle>
<blockTableStyle id="TOP_TABLE">
<blockAlignment value="LEFT"/>
<blockValign value="TOP"/>
<lineStyle kind="LINEBELOW" colorName="#FFFFFF" start="0,-1" stop="0,-1" thickness='0.25'/>
</blockTableStyle>
<initialize>
<paraStyle name="all" alignment="justify"/>
</initialize>
<paraStyle
name="TITLE_LEFT_ALIGN"
fontName="Helvetica-Bold"
fontSize="6.0"
leading="10"
alignment="RIGHT"
spaceBefore="0.0"
spaceAfter="0.0"/>
<paraStyle name="TOP_TITLE" fontName="Helvetica-Bold" fontSize="7" leftIndent="0.0" alignment="LEFT"/>
<paraStyle name="TITLES" fontName="Helvetica-Bold" fontSize="6.0" leading="10" alignment="LEFT" spaceBefore="0.0" spaceAfter="0.0"/>
<paraStyle name="TITLE_CENTER" fontName="Helvetica-Bold" fontSize="7" leading="10" leftIndent="0.0" alignment="CENTER"/>
<paraStyle name="TITLE_CENTER_NAME" fontName="Helvetica-Bold" fontSize="12" leading="13" leftIndent="0.0" alignment="CENTER"/>
<paraStyle name="TITLE" alignment="CENTER" fontName="Helvetica" fontSize="18.0" leading="20" spaceBefore="-3.0" textColor="black"/>
</stylesheet>
<images/>
<story>
<para>[[setLang(user.context_lang)]]</para>
<blockTable colWidths="2.0cm,6.5cm,2.5cm,2.5cm,2.5cm,2.5cm,2.5cm,2.5cm,2.5cm,2.5cm,2.5cm,2.5cm,2.5cm,2.5cm,2.5cm" style="BODY" repeatRows="1">
<tr noRowsplits="1">
<td>
<para style="TITLE_LEFT_ALIGN">
<font>CODE</font>
</para>
</td>
<td>
<para style="TITLES">ACCOUNT</para>
</td>
<td>
<para style="TITLE_LEFT_ALIGN">01</para>
</td>
<td>
<para style="TITLE_LEFT_ALIGN">02</para>
</td>
<td>
<para style="TITLE_LEFT_ALIGN">03</para>
</td>
<td>
<para style="TITLE_LEFT_ALIGN">04</para>
</td>
<td>
<para style="TITLE_LEFT_ALIGN">05</para>
</td>
<td>
<para style="TITLE_LEFT_ALIGN">06</para>
</td>
<td>
<para style="TITLE_LEFT_ALIGN">07</para>
</td>
<td>
<para style="TITLE_LEFT_ALIGN">08</para>
</td>
<td>
<para style="TITLE_LEFT_ALIGN">09</para>
</td>
<td>
<para style="TITLE_LEFT_ALIGN">10</para>
</td>
<td>
<para style="TITLE_LEFT_ALIGN">11</para>
</td>
<td>
<para style="TITLE_LEFT_ALIGN">12</para>
</td>
<td>
<para style="TITLE_LEFT_ALIGN">YTD</para>
</td>
</tr>
<tr>
<td>
<para style="TITLE_LEFT_ALIGN">[[ repeatIn(lines(data['form']), 'a') ]]
<font>[[ a['type']&lt;&gt;'view' and setTag('para','para',{'fontName':"Courier"}) or removeParentNode('font') ]]</font>
<i>[[a['label']==True and a['code'] or '' ]]</i>
</para>
</td>
<td>
<para style="TITLES">
<font>[[ ((a['total'] and not a['label']) and setTag('para','para',{'alignment':"RIGHT"}) or (a['type']&lt;&gt;'view' and setTag('para','para',{'fontName':"Courier"}))) or removeParentNode('font') ]]</font>
<font>[[ a['type']=='view' and a['name'].upper() or a['name'].title() ]]</font>
</para>
</td>
<td>
<para style="TITLE_LEFT_ALIGN">
<font>[[ a['type']&lt;&gt;'view' and setTag('para','para',{'fontName':"Courier"}) or removeParentNode('font') ]]</font>
<font>[[ (a['total']==True) and formatLang(a['bal1'] and a['bal1'] * a.get('change_sign') or 0.0, digits=2, grouping=True) or '']]</font>
</para>
</td>
<td>
<para style="TITLE_LEFT_ALIGN">
<font>[[ a['type']&lt;&gt;'view' and setTag('para','para',{'fontName':"Courier"}) or removeParentNode('font') ]]</font>
<font>[[ (a['total']==True) and formatLang(a['bal2'] and a['bal2'] * a.get('change_sign') or 0.0, digits=2, grouping=True) or '']]</font>
</para>
</td>
<td>
<para style="TITLE_LEFT_ALIGN">
<font>[[ a['type']&lt;&gt;'view' and setTag('para','para',{'fontName':"Courier"}) or removeParentNode('font') ]]</font>
<font>[[ (a['total']==True) and formatLang(a['bal3'] and a['bal3'] * a.get('change_sign') or 0.0, digits=2, grouping=True) or '']]</font>
</para>
</td>
<td>
<para style="TITLE_LEFT_ALIGN">
<font>[[ a['type']&lt;&gt;'view' and setTag('para','para',{'fontName':"Courier"}) or removeParentNode('font') ]]</font>
<font>[[ (a['total']==True) and formatLang(a['bal4'] and a['bal4'] * a.get('change_sign') or 0.0, digits=2, grouping=True) or '']]</font>
</para>
</td>
<td>
<para style="TITLE_LEFT_ALIGN">
<font>[[ a['type']&lt;&gt;'view' and setTag('para','para',{'fontName':"Courier"}) or removeParentNode('font') ]]</font>
<font>[[ (a['total']==True) and formatLang(a['bal5'] and a['bal5'] * a.get('change_sign') or 0.0, digits=2, grouping=True) or '']]</font>
</para>
</td>
<td>
<para style="TITLE_LEFT_ALIGN">
<font>[[ a['type']&lt;&gt;'view' and setTag('para','para',{'fontName':"Courier"}) or removeParentNode('font') ]]</font>
<font>[[ (a['total']==True) and formatLang(a['bal6'] and a['bal6'] * a.get('change_sign') or 0.0, digits=2, grouping=True) or '']]</font>
</para>
</td>
<td>
<para style="TITLE_LEFT_ALIGN">
<font>[[ a['type']&lt;&gt;'view' and setTag('para','para',{'fontName':"Courier"}) or removeParentNode('font') ]]</font>
<font>[[ (a['total']==True) and formatLang(a['bal7'] and a['bal7'] * a.get('change_sign') or 0.0, digits=2, grouping=True) or '']]</font>
</para>
</td>
<td>
<para style="TITLE_LEFT_ALIGN">
<font>[[ a['type']&lt;&gt;'view' and setTag('para','para',{'fontName':"Courier"}) or removeParentNode('font') ]]</font>
<font>[[ (a['total']==True) and formatLang(a['bal8'] and a['bal8'] * a.get('change_sign') or 0.0, digits=2, grouping=True) or '']]</font>
</para>
</td>
<td>
<para style="TITLE_LEFT_ALIGN">
<font>[[ a['type']&lt;&gt;'view' and setTag('para','para',{'fontName':"Courier"}) or removeParentNode('font') ]]</font>
<font>[[ (a['total']==True) and formatLang(a['bal9'] and a['bal9'] * a.get('change_sign') or 0.0, digits=2, grouping=True) or '']]</font>
</para>
</td>
<td>
<para style="TITLE_LEFT_ALIGN">
<font>[[ a['type']&lt;&gt;'view' and setTag('para','para',{'fontName':"Courier"}) or removeParentNode('font') ]]</font>
<font>[[ (a['total']==True) and formatLang(a['bal10'] and a['bal10'] * a.get('change_sign') or 0.0, digits=2, grouping=True) or '']]</font>
</para>
</td>
<td>
<para style="TITLE_LEFT_ALIGN">
<font>[[ a['type']&lt;&gt;'view' and setTag('para','para',{'fontName':"Courier"}) or removeParentNode('font') ]]</font>
<font>[[ (a['total']==True) and formatLang(a['bal11'] and a['bal11'] * a.get('change_sign') or 0.0, digits=2, grouping=True) or '']]</font>
</para>
</td>
<td>
<para style="TITLE_LEFT_ALIGN">
<font>[[ a['type']&lt;&gt;'view' and setTag('para','para',{'fontName':"Courier"}) or removeParentNode('font') ]]</font>
<font>[[ (a['total']==True) and formatLang(a['bal12'] and a['bal12'] * a.get('change_sign') or 0.0, digits=2, grouping=True) or '']]</font>
</para>
</td>
<td>
<para style="TITLE_LEFT_ALIGN">
<font>[[ a['type']&lt;&gt;'view' and setTag('para','para',{'fontName':"Courier"}) or removeParentNode('font') ]]</font>
<font>[[ (a['total']==True) and formatLang(a['bal13'] and a['bal13'] * a.get('change_sign') or 0.0, digits=2, grouping=True) or '']]</font>
</para>
</td>
</tr>
</blockTable>
</story>
</document>

15
account_financial_report/report/balance_full_2_cols.rml

@ -5,6 +5,11 @@
<frame id="first" x1="1cm" y1="1.0cm" width="19.0cm" height="23cm"/> <frame id="first" x1="1cm" y1="1.0cm" width="19.0cm" height="23cm"/>
<pageGraphics> <pageGraphics>
<setFont name="Helvetica" size="9"/> <setFont name="Helvetica" size="9"/>
<image x="1.0cm" y="24.0cm" width="5.0cm">[[company.logo and company.logo or removeParentNode('image')]]</image>
<!--
<drawString x="1.0cm" y="24.5cm">[[company.logo and removeParentNode('para') or company.name]]</drawString>
-->
<place x="-3.5cm" y="22.50cm" width="19cm" height="5.0cm"> <place x="-3.5cm" y="22.50cm" width="19cm" height="5.0cm">
<blockTable colWidths="9.6cm,9.4cm" style="TITLE"> <blockTable colWidths="9.6cm,9.4cm" style="TITLE">
<tr> <tr>
@ -20,7 +25,7 @@
</tr> </tr>
<tr> <tr>
<td><para style="TOP_TITLE"></para></td> <td><para style="TOP_TITLE"></para></td>
<td><para style="TITLE_CENTER">[[data['form'] and (' (Expresado en %s)'%( exchange_name(data['form']))) or '']]</para></td>
<td><para style="TITLE_CENTER">[[data['form'] and (' (Expressed in %s)'%( exchange_name(data['form']))) or '']]</para></td>
</tr> </tr>
<tr> <tr>
<td><para style="TOP_TITLE"></para></td> <td><para style="TOP_TITLE"></para></td>
@ -81,17 +86,17 @@
<tr noRowsplits="1"> <tr noRowsplits="1">
<td> <td>
<para style="TITLE_LEFT_ALIGN"> <para style="TITLE_LEFT_ALIGN">
<font>Código</font>
<font>CODE</font>
</para> </para>
</td> </td>
<td> <td>
<para style="TITLES">Cuenta</para>
<para style="TITLES">ACCOUNT</para>
</td> </td>
<td> <td>
<para style="TITLE_LEFT_ALIGN">Débito</para>
<para style="TITLE_LEFT_ALIGN">DEBIT</para>
</td> </td>
<td> <td>
<para style="TITLE_LEFT_ALIGN">Crédito</para>
<para style="TITLE_LEFT_ALIGN">CREDIT</para>
</td> </td>
</tr> </tr>
<tr> <tr>

20
account_financial_report/report/balance_full_4_cols.rml

@ -6,8 +6,8 @@
<pageGraphics> <pageGraphics>
<setFont name="Helvetica" size="9"/> <setFont name="Helvetica" size="9"/>
<image x="1.0cm" y="24.0cm" width="5.0cm">[[company.logo and company.logo or removeParentNode('image')]]</image>
<!-- <!--
<image x="1.0cm" y="25.0cm" height="2.5cm" width="9.6cm">[[company.logo and company.logo or removeParentNode('image')]]</image>
<drawString x="1.0cm" y="24.5cm">[[company.logo and removeParentNode('para') or company.name]]</drawString> <drawString x="1.0cm" y="24.5cm">[[company.logo and removeParentNode('para') or company.name]]</drawString>
--> -->
@ -26,7 +26,7 @@
</tr> </tr>
<tr> <tr>
<td><para style="TOP_TITLE"></para></td> <td><para style="TOP_TITLE"></para></td>
<td><para style="TITLE_CENTER">[[data['form'] and (' (Expresado en %s)'%( exchange_name(data['form']))) or '']]</para></td>
<td><para style="TITLE_CENTER">[[data['form'] and (' (Expressed in %s)'%( exchange_name(data['form']))) or '']]</para></td>
</tr> </tr>
<tr> <tr>
<td><para style="TOP_TITLE"></para></td> <td><para style="TOP_TITLE"></para></td>
@ -87,23 +87,23 @@
<tr noRowsplits="1"> <tr noRowsplits="1">
<td> <td>
<para style="TITLE_LEFT_ALIGN"> <para style="TITLE_LEFT_ALIGN">
<font>Código</font>
<font>CODE</font>
</para> </para>
</td> </td>
<td> <td>
<para style="TITLES">Cuenta</para>
<para style="TITLES">ACCOUNT</para>
</td> </td>
<td> <td>
<para style="TITLE_LEFT_ALIGN">Inicial</para>
<para style="TITLE_LEFT_ALIGN">INITIAL</para>
</td> </td>
<td> <td>
<para style="TITLE_LEFT_ALIGN">Débito</para>
<para style="TITLE_LEFT_ALIGN">DEBIT</para>
</td> </td>
<td> <td>
<para style="TITLE_LEFT_ALIGN">Crédito</para>
<para style="TITLE_LEFT_ALIGN">CREDIT</para>
</td> </td>
<td> <td>
<para style="TITLE_LEFT_ALIGN">Balance</para>
<para style="TITLE_LEFT_ALIGN">BALANCE</para>
</td> </td>
</tr> </tr>
<tr> <tr>
@ -122,7 +122,7 @@
<td> <td>
<para style="TITLE_LEFT_ALIGN"> <para style="TITLE_LEFT_ALIGN">
<font>[[ a['type']&lt;&gt;'view' and setTag('para','para',{'fontName':"Courier"}) or removeParentNode('font') ]]</font> <font>[[ a['type']&lt;&gt;'view' and setTag('para','para',{'fontName':"Courier"}) or removeParentNode('font') ]]</font>
<font>[[ (a['total']==True) and formatLang(a['balanceinit'], digits=2, grouping=True) or '']]</font>
<font>[[ (a['total']==True) and formatLang(a['balanceinit'] and a['balanceinit'] * a.get('change_sign') or 0.0, digits=2, grouping=True) or '']]</font>
</para> </para>
</td> </td>
<td> <td>
@ -140,7 +140,7 @@
<td> <td>
<para style="TITLE_LEFT_ALIGN"> <para style="TITLE_LEFT_ALIGN">
<font>[[ a['type']&lt;&gt;'view' and setTag('para','para',{'fontName':"Courier"}) or removeParentNode('font') ]]</font> <font>[[ a['type']&lt;&gt;'view' and setTag('para','para',{'fontName':"Courier"}) or removeParentNode('font') ]]</font>
<font>[[ (a['total']==True) and formatLang(a['balance'], digits=2, grouping=True) or '']]</font>
<font>[[ (a['total']==True) and formatLang(a['balance'] and a['balance'] * a.get('change_sign') or 0.0, digits=2, grouping=True) or '']]</font>
</para> </para>
</td> </td>
</tr> </tr>

294
account_financial_report/report/balance_full_4_cols_analytic_ledger.rml

@ -0,0 +1,294 @@
<?xml version="1.0"?>
<document filename="test.pdf">
<template pageSize="(27.94cm,21.59cm)" title="Test" author="Martin Simon" allowSplitting="20" showBoundary="0">
<pageTemplate id="first">
<frame id="first" x1="1.0cm" y1="1.0cm" width="26.0cm" height="16.65cm"/>
<pageGraphics>
<setFont name="Helvetica" size="9"/>
<image x="1.0cm" y="17.65cm" width="5.0cm">[[company.logo and company.logo or removeParentNode('image')]]</image>
<!--
<drawString x="1.0cm" y="24.5cm">[[company.logo and removeParentNode('para') or company.name]]</drawString>
-->
<place x="-3.5cm" y="16.15cm" width="19cm" height="5.0cm">
<blockTable colWidths="9.6cm,9.4cm" style="TITLE">
<tr>
<td><para style="TOP_TITLE"></para></td>
<td><para style="TITLE_CENTER_NAME">
<font>[[ (company.name and company.name or 'NOMBRE DE COMPANIA NO DISPONIBLE')]]</font>
<font>[[ company.partner_id.vat and ('- %s-%s-%s'%(company.partner_id.vat[2:3],company.partner_id.vat[3:11],company.partner_id.vat[11:12])) or '' ]]</font>
</para></td>
</tr>
<tr>
<td><para style="TOP_TITLE"></para></td>
<td><para style="TITLE_CENTER">[[ get_informe_text(data['form']) ]]</para></td>
</tr>
<tr>
<td><para style="TOP_TITLE"></para></td>
<td><para style="TITLE_CENTER">[[data['form'] and (' (Expressed in %s)'%( exchange_name(data['form']))) or '']]</para></td>
</tr>
<tr>
<td><para style="TOP_TITLE"></para></td>
<td><para style="TITLE_CENTER">[[data['form'] and get_month(data['form']) or '']]</para></td>
</tr>
</blockTable>
</place>
<drawRightString x="270mm" y="5mm"> Pag.: <pageNumber/></drawRightString>
</pageGraphics>
</pageTemplate>
</template>
<stylesheet>
<blockTableStyle id="BODY_LINE">
<blockValign value="TOP"/>
<blockAlignment value="RIGHT"/>
<blockTopPadding length="1.0"/>
<blockBottomPadding length="1.0"/>
<lineStyle kind="LINEBELOW" colorName="#e6e6e6" start="0,0" stop="-1,-1" thickness='0.25'/>
</blockTableStyle>
<blockTableStyle id="TITLE">
<blockValign value="TOP"/>
</blockTableStyle>
<blockTableStyle id="BODY">
<blockValign value="TOP"/>
<blockAlignment value="RIGHT"/>
<blockTopPadding length="1.0"/>
<blockBottomPadding length="1.0"/>
<lineStyle kind="LINEBELOW" colorName="darkgrey" start="0,0" stop="-1,-1" thickness='0.25'/>
</blockTableStyle>
<blockTableStyle id="BODY_STRIKE">
<blockValign value="TOP"/>
<blockAlignment value="RIGHT"/>
<blockTopPadding length="1.0"/>
<blockBottomPadding length="1.0"/>
<lineStyle kind="LINEBELOW" colorName="#FFFFFF" start="0,1" stop="-1,-1" thickness='0.5'/>
</blockTableStyle>
<blockTableStyle id="TOP_TABLE">
<blockAlignment value="LEFT"/>
<blockValign value="TOP"/>
<lineStyle kind="LINEBELOW" colorName="#FFFFFF" start="0,-1" stop="0,-1" thickness='0.25'/>
</blockTableStyle>
<initialize>
<paraStyle name="all" alignment="justify"/>
</initialize>
<paraStyle
name="TITLE_LEFT_ALIGN_NEW"
fontName="Courier"
fontSize="7.0"
leading="10"
alignment="RIGHT"
spaceBefore="0.0"
spaceAfter="0.0"/>
<paraStyle name="TITLES_NEW"
fontName="Courier"
fontSize="7.0"
leading="10"
alignment="LEFT"
spaceBefore="0.0"
spaceAfter="0.0"/>
<paraStyle
name="TITLE_LEFT_ALIGN"
fontName="Helvetica-Bold"
fontSize="7.0"
leading="10"
alignment="RIGHT"
spaceBefore="0.0"
spaceAfter="0.0"/>
<paraStyle name="TOP_TITLE" fontName="Helvetica-Bold" fontSize="7" leftIndent="0.0" alignment="LEFT"/>
<paraStyle
name="TITLES"
fontName="Helvetica-Bold"
fontSize="7.0"
leading="10"
alignment="LEFT"
spaceBefore="0.0"
spaceAfter="0.0"/>
<paraStyle name="TITLE_CENTER" fontName="Helvetica-Bold" fontSize="7" leading="10" leftIndent="0.0" alignment="CENTER"/>
<paraStyle name="TITLE_CENTER_NAME" fontName="Helvetica-Bold" fontSize="12" leading="13" leftIndent="0.0" alignment="CENTER"/>
<paraStyle
name="TITLE"
alignment="CENTER"
fontName="Helvetica"
fontSize="18.0"
leading="20"
spaceBefore="-3.0"
textColor="black"/>
</stylesheet>
<images/>
<story>
<para>[[setLang(user.context_lang)]]</para>
<blockTable colWidths="2.5cm,13.5cm,2.5cm,2.5cm,2.5cm,2.5cm" style="BODY" repeatRows="0">
<tr noRowsplits="0">
<td>
<para style="TITLE_LEFT_ALIGN">
<font>CODE</font>
</para>
</td>
<td>
<para style="TITLES">ACCOUNT</para>
</td>
<td>
<para style="TITLE_LEFT_ALIGN">INITIAL</para>
</td>
<td>
<para style="TITLE_LEFT_ALIGN">DEBIT</para>
</td>
<td>
<para style="TITLE_LEFT_ALIGN">CREDIT</para>
</td>
<td>
<para style="TITLE_LEFT_ALIGN">BALANCE</para>
</td>
</tr>
</blockTable>
<blockTable colWidths="2.25cm,2.0cm,7.75cm,2.5cm,4.0cm,2.5cm,2.5cm,2.5cm" style="BODY_LINE" repeatRows="1">
<!--
[[ (a['type'] &lt;&gt; 'view') or removeParentNode('blockTable') ]]
-->
<tr noRowsplits="1">
<td>
<para style="TITLES_NEW">
<font>DATE</font>
</para>
</td>
<td>
<para style="TITLES_NEW">
<font>PERIOD</font>
</para>
</td>
<td>
<para style="TITLES_NEW">REFERENCE</para>
</td>
<td>
<para style="TITLES_NEW">JOURNAL ENTRY</para>
</td>
<td>
<para style="TITLES_NEW">PARTNER</para>
</td>
<td>
<para style="TITLE_LEFT_ALIGN"></para>
</td>
<td>
<para style="TITLE_LEFT_ALIGN"></para>
</td>
<td>
<para style="TITLE_LEFT_ALIGN"></para>
</td>
</tr>
</blockTable>
<section>
<para>[[ repeatIn([x for x in lines(data['form']) if x['type'] != 'view'], 'a') ]]</para>
<blockTable colWidths="2.5cm,13.5cm,2.5cm,2.5cm,2.5cm,2.5cm" style="BODY" repeatRows="0">
<tr>
<td>
<para style="TITLE_LEFT_ALIGN">
<font>[[ a['type']&lt;&gt;'view' and setTag('para','para',{'fontName':"Courier-Bold"}) or removeParentNode('font') ]]</font>
<i>[[a['label']==True and a['code'] or '' ]]</i>
</para>
</td>
<td>
<para style="TITLES">
<font>[[ ((a['total'] and not a['label']) and setTag('para','para',{'alignment':"RIGHT"}) or (a['type']&lt;&gt;'view' and setTag('para','para',{'fontName':"Courier-Bold"}))) or removeParentNode('font') ]]</font>
<font>[[ a['type']=='view' and a['name'].upper() or a['name'].title() ]]</font>
</para>
</td>
<td>
<para style="TITLE_LEFT_ALIGN">
<font>[[ a['type']&lt;&gt;'view' and setTag('para','para',{'fontName':"Courier-Bold"}) or removeParentNode('font') ]]</font>
<font>[[ (a['total']==True) and formatLang(a['balanceinit'] and a['balanceinit'] * a.get('change_sign') or 0.0, digits=2, grouping=True) or '']]</font>
</para>
</td>
<td>
<para style="TITLE_LEFT_ALIGN">
<font>[[ a['type']&lt;&gt;'view' and setTag('para','para',{'fontName':"Courier-Bold"}) or removeParentNode('font') ]]</font>
<font>[[ (a['total']==True) and formatLang(a['debit'], digits=2, grouping=True) or '']]</font>
</para>
</td>
<td>
<para style="TITLE_LEFT_ALIGN">
<font>[[ a['type']&lt;&gt;'view' and setTag('para','para',{'fontName':"Courier-Bold"}) or removeParentNode('font') ]]</font>
<font>[[ (a['total']==True) and formatLang(a['credit'], digits=2, grouping=True) or '']]</font>
</para>
</td>
<td>
<para style="TITLE_LEFT_ALIGN">
<font>[[ a['type']&lt;&gt;'view' and setTag('para','para',{'fontName':"Courier-Bold"}) or removeParentNode('font') ]]</font>
<font>[[ (a['total']==True) and formatLang(a['balance'] and a['balance'] * a.get('change_sign') or 0.0, digits=2, grouping=True) or '']]</font>
</para>
</td>
</tr>
</blockTable>
<section>
<para>[[ repeatIn(a['mayor'], 'm') ]]</para>
<blockTable colWidths="2.25cm,2.0cm,7.75cm,2.5cm,4.0cm,2.5cm,2.5cm,2.5cm" style="BODY_LINE" repeatRows="1">
<!--
[[ (a['type'] &lt;&gt; 'view') or removeParentNode('blockTable') ]]
-->
<tr>
<td>
<para style="TITLES_NEW">
<font> [[ formatLang( m['date'], date=True) ]]</font>
</para>
</td>
<td>
<para style="TITLES_NEW">
<font>[[ m['period'] ]]</font>
</para>
</td>
<td>
<para style="TITLES_NEW">
<font>[[ m['name'] ]] [[ m['ref'] and (' - Ref %s'%m['ref']) or '' ]] </font>
</para>
</td>
<td>
<para style="TITLES_NEW">
<font>[[ m['entry'] ]]</font>
</para>
<!--
<para style="TITLES_NEW">
<font>[[ m['journal'] ]]</font>
</para>
-->
</td>
<td>
<para style="TITLES_NEW">
<font>[[ m['partner'] ]]</font>
</para>
</td>
<td>
<para style="TITLE_LEFT_ALIGN">
<font>[[ a['type']&lt;&gt;'view' and setTag('para','para',{'fontName':"Courier"}) or removeParentNode('font') ]]</font>
<font>[[ (a['total']==True) and formatLang(m['debit'], digits=2, grouping=True) or '']]</font>
</para>
</td>
<td>
<para style="TITLE_LEFT_ALIGN">
<font>[[ a['type']&lt;&gt;'view' and setTag('para','para',{'fontName':"Courier"}) or removeParentNode('font') ]]</font>
<font>[[ (a['total']==True) and formatLang(m['credit'], digits=2, grouping=True) or '']]</font>
</para>
</td>
<td>
<para style="TITLE_LEFT_ALIGN">
<font>[[ a['type']&lt;&gt;'view' and setTag('para','para',{'fontName':"Courier"}) or removeParentNode('font') ]]</font>
<font>[[ (a['total']==True) and formatLang(m['balance'] and m['balance'] * a.get('change_sign') or 0.0, digits=2, grouping=True) or '']]</font>
</para>
</td>
</tr>
</blockTable>
</section>
<spacer length="2.5mm"/>
</section>
</story>
</document>

158
account_financial_report/report/balance_full_5_cols.rml

@ -0,0 +1,158 @@
<?xml version="1.0"?>
<document filename="test.pdf">
<template pageSize="(21.59cm,27.94cm)" title="Test" author="Martin Simon" allowSplitting="20" showBoundary="0">
<pageTemplate id="first">
<frame id="first" x1="0.5cm" y1="1.0cm" width="20.5cm" height="23cm"/>
<pageGraphics>
<setFont name="Helvetica" size="9"/>
<image x="1.0cm" y="24.0cm" width="5.0cm">[[company.logo and company.logo or removeParentNode('image')]]</image>
<!--
<drawString x="1.0cm" y="24.5cm">[[company.logo and removeParentNode('para') or company.name]]</drawString>
-->
<place x="-3.5cm" y="22.50cm" width="19cm" height="5.0cm">
<blockTable colWidths="9.6cm,9.4cm" style="TITLE">
<tr>
<td><para style="TOP_TITLE"></para></td>
<td><para style="TITLE_CENTER_NAME">
<font>[[ (company.name and company.name or 'NOMBRE DE COMPANIA NO DISPONIBLE')]]</font>
<font>[[ company.partner_id.vat and ('- %s-%s-%s'%(company.partner_id.vat[2:3],company.partner_id.vat[3:11],company.partner_id.vat[11:12])) or '' ]]</font>
</para></td>
</tr>
<tr>
<td><para style="TOP_TITLE"></para></td>
<td><para style="TITLE_CENTER">[[ get_informe_text(data['form']) ]]</para></td>
</tr>
<tr>
<td><para style="TOP_TITLE"></para></td>
<td><para style="TITLE_CENTER">[[data['form'] and (' (Expressed in %s)'%( exchange_name(data['form']))) or '']]</para></td>
</tr>
<tr>
<td><para style="TOP_TITLE"></para></td>
<td><para style="TITLE_CENTER">[[data['form'] and get_month(data['form']) or '']]</para></td>
</tr>
</blockTable>
</place>
<drawRightString x="192mm" y="5mm">[[ get_informe_text(data['form']) ]] / Pág.: <pageNumber/>-<pageCount/> </drawRightString>
</pageGraphics>
</pageTemplate>
</template>
<stylesheet>
<blockTableStyle id="TITLE">
<blockValign value="TOP"/>
</blockTableStyle>
<blockTableStyle id="BODY">
<blockValign value="TOP"/>
<blockAlignment value="RIGHT"/>
<blockTopPadding length="1.0"/>
<blockBottomPadding length="1.0"/>
<lineStyle kind="LINEBELOW" colorName="#e6e6e6" start="0,1" stop="-1,-1" thickness='0.25'/>
</blockTableStyle>
<blockTableStyle id="BODY_STRIKE">
<blockValign value="TOP"/>
<blockAlignment value="RIGHT"/>
<blockTopPadding length="1.0"/>
<blockBottomPadding length="1.0"/>
<lineStyle kind="LINEBELOW" colorName="#FFFFFF" start="0,1" stop="-1,-1" thickness='0.5'/>
</blockTableStyle>
<blockTableStyle id="TOP_TABLE">
<blockAlignment value="LEFT"/>
<blockValign value="TOP"/>
<lineStyle kind="LINEBELOW" colorName="#FFFFFF" start="0,-1" stop="0,-1" thickness='0.25'/>
</blockTableStyle>
<initialize>
<paraStyle name="all" alignment="justify"/>
</initialize>
<paraStyle
name="TITLE_LEFT_ALIGN"
fontName="Helvetica-Bold"
fontSize="6.0"
leading="10"
alignment="RIGHT"
spaceBefore="0.0"
spaceAfter="0.0"/>
<paraStyle name="TOP_TITLE" fontName="Helvetica-Bold" fontSize="7" leftIndent="0.0" alignment="LEFT"/>
<paraStyle name="TITLES" fontName="Helvetica-Bold" fontSize="6.0" leading="10" alignment="LEFT" spaceBefore="0.0" spaceAfter="0.0"/>
<paraStyle name="TITLE_CENTER" fontName="Helvetica-Bold" fontSize="7" leading="10" leftIndent="0.0" alignment="CENTER"/>
<paraStyle name="TITLE_CENTER_NAME" fontName="Helvetica-Bold" fontSize="12" leading="13" leftIndent="0.0" alignment="CENTER"/>
<paraStyle name="TITLE" alignment="CENTER" fontName="Helvetica" fontSize="18.0" leading="20" spaceBefore="-3.0" textColor="black"/>
</stylesheet>
<images/>
<story>
<para>[[setLang(user.context_lang)]]</para>
<blockTable colWidths="2.5cm,6.0cm,2.5cm,2.5cm,2.5cm,2.5cm,2.5cm" style="BODY" repeatRows="1">
<tr noRowsplits="1">
<td>
<para style="TITLE_LEFT_ALIGN">
<font>Code</font>
</para>
</td>
<td>
<para style="TITLES">ACCOUNT</para>
</td>
<td>
<para style="TITLE_LEFT_ALIGN">INIT. BAL.</para>
</td>
<td>
<para style="TITLE_LEFT_ALIGN">DEBIT</para>
</td>
<td>
<para style="TITLE_LEFT_ALIGN">CREDIT</para>
</td>
<td>
<para style="TITLE_LEFT_ALIGN">PERIOD</para>
</td>
<td>
<para style="TITLE_LEFT_ALIGN">YTD</para>
</td>
</tr>
<tr>
<td>
<para style="TITLE_LEFT_ALIGN">[[ repeatIn(lines(data['form']), 'a') ]]
<font>[[ a['type']&lt;&gt;'view' and setTag('para','para',{'fontName':"Courier"}) or removeParentNode('font') ]]</font>
<i>[[a['label']==True and a['code'] or '' ]]</i>
</para>
</td>
<td>
<para style="TITLES">
<font>[[ ((a['total'] and not a['label']) and setTag('para','para',{'alignment':"RIGHT"}) or (a['type']&lt;&gt;'view' and setTag('para','para',{'fontName':"Courier"}))) or removeParentNode('font') ]]</font>
<font>[[ a['type']=='view' and a['name'].upper() or a['name'].title() ]]</font>
</para>
</td>
<td>
<para style="TITLE_LEFT_ALIGN">
<font>[[ a['type']&lt;&gt;'view' and setTag('para','para',{'fontName':"Courier"}) or removeParentNode('font') ]]</font>
<font>[[ (a['total']==True) and formatLang(a['balanceinit'] and a['balanceinit'] * a.get('change_sign') or 0.0, digits=2, grouping=True) or '']]</font>
</para>
</td>
<td>
<para style="TITLE_LEFT_ALIGN">
<font>[[ a['type']&lt;&gt;'view' and setTag('para','para',{'fontName':"Courier"}) or removeParentNode('font') ]]</font>
<font>[[ (a['total']==True) and formatLang(a['debit'], digits=2, grouping=True) or '']]</font>
</para>
</td>
<td>
<para style="TITLE_LEFT_ALIGN">
<font>[[ a['type']&lt;&gt;'view' and setTag('para','para',{'fontName':"Courier"}) or removeParentNode('font') ]]</font>
<font>[[ (a['total']==True) and formatLang(a['credit'], digits=2, grouping=True) or '']]</font>
</para>
</td>
<td>
<para style="TITLE_LEFT_ALIGN">
<font>[[ a['type']&lt;&gt;'view' and setTag('para','para',{'fontName':"Courier"}) or removeParentNode('font') ]]</font>
<font>[[ (a['total']==True) and formatLang(a['ytd'] and a['ytd'] * a.get('change_sign') or 0.0, digits=2, grouping=True) or '']]</font>
</para>
</td>
<td>
<para style="TITLE_LEFT_ALIGN">
<font>[[ a['type']&lt;&gt;'view' and setTag('para','para',{'fontName':"Courier"}) or removeParentNode('font') ]]</font>
<font>[[ (a['total']==True) and formatLang(a['balance'] and a['balance'] * a.get('change_sign') or 0.0, digits=2, grouping=True) or '']]</font>
</para>
</td>
</tr>
</blockTable>
</story>
</document>

158
account_financial_report/report/balance_full_qtr_cols.rml

@ -0,0 +1,158 @@
<?xml version="1.0"?>
<document filename="test.pdf">
<template pageSize="(21.59cm,27.94cm)" title="Test" author="Martin Simon" allowSplitting="20" showBoundary="0">
<pageTemplate id="first">
<frame id="first" x1="0.5cm" y1="1.0cm" width="20.5cm" height="23cm"/>
<pageGraphics>
<setFont name="Helvetica" size="9"/>
<image x="1.0cm" y="24.0cm" width="5.0cm">[[company.logo and company.logo or removeParentNode('image')]]</image>
<!--
<drawString x="1.0cm" y="24.5cm">[[company.logo and removeParentNode('para') or company.name]]</drawString>
-->
<place x="-3.5cm" y="22.50cm" width="19cm" height="5.0cm">
<blockTable colWidths="9.6cm,9.4cm" style="TITLE">
<tr>
<td><para style="TOP_TITLE"></para></td>
<td><para style="TITLE_CENTER_NAME">
<font>[[ (company.name and company.name or 'NOMBRE DE COMPANIA NO DISPONIBLE')]]</font>
<font>[[ company.partner_id.vat and ('- %s-%s-%s'%(company.partner_id.vat[2:3],company.partner_id.vat[3:11],company.partner_id.vat[11:12])) or '' ]]</font>
</para></td>
</tr>
<tr>
<td><para style="TOP_TITLE"></para></td>
<td><para style="TITLE_CENTER">[[ get_informe_text(data['form']) ]]</para></td>
</tr>
<tr>
<td><para style="TOP_TITLE"></para></td>
<td><para style="TITLE_CENTER">[[data['form'] and (' (Expressed in %s)'%( exchange_name(data['form']))) or '']]</para></td>
</tr>
<tr>
<td><para style="TOP_TITLE"></para></td>
<td><para style="TITLE_CENTER">[[data['form'] and get_month(data['form']) or '']]</para></td>
</tr>
</blockTable>
</place>
<drawRightString x="192mm" y="5mm">[[ get_informe_text(data['form']) ]] / Pág.: <pageNumber/>-<pageCount/> </drawRightString>
</pageGraphics>
</pageTemplate>
</template>
<stylesheet>
<blockTableStyle id="TITLE">
<blockValign value="TOP"/>
</blockTableStyle>
<blockTableStyle id="BODY">
<blockValign value="TOP"/>
<blockAlignment value="RIGHT"/>
<blockTopPadding length="1.0"/>
<blockBottomPadding length="1.0"/>
<lineStyle kind="LINEBELOW" colorName="#e6e6e6" start="0,1" stop="-1,-1" thickness='0.25'/>
</blockTableStyle>
<blockTableStyle id="BODY_STRIKE">
<blockValign value="TOP"/>
<blockAlignment value="RIGHT"/>
<blockTopPadding length="1.0"/>
<blockBottomPadding length="1.0"/>
<lineStyle kind="LINEBELOW" colorName="#FFFFFF" start="0,1" stop="-1,-1" thickness='0.5'/>
</blockTableStyle>
<blockTableStyle id="TOP_TABLE">
<blockAlignment value="LEFT"/>
<blockValign value="TOP"/>
<lineStyle kind="LINEBELOW" colorName="#FFFFFF" start="0,-1" stop="0,-1" thickness='0.25'/>
</blockTableStyle>
<initialize>
<paraStyle name="all" alignment="justify"/>
</initialize>
<paraStyle
name="TITLE_LEFT_ALIGN"
fontName="Helvetica-Bold"
fontSize="6.0"
leading="10"
alignment="RIGHT"
spaceBefore="0.0"
spaceAfter="0.0"/>
<paraStyle name="TOP_TITLE" fontName="Helvetica-Bold" fontSize="7" leftIndent="0.0" alignment="LEFT"/>
<paraStyle name="TITLES" fontName="Helvetica-Bold" fontSize="6.0" leading="10" alignment="LEFT" spaceBefore="0.0" spaceAfter="0.0"/>
<paraStyle name="TITLE_CENTER" fontName="Helvetica-Bold" fontSize="7" leading="10" leftIndent="0.0" alignment="CENTER"/>
<paraStyle name="TITLE_CENTER_NAME" fontName="Helvetica-Bold" fontSize="12" leading="13" leftIndent="0.0" alignment="CENTER"/>
<paraStyle name="TITLE" alignment="CENTER" fontName="Helvetica" fontSize="18.0" leading="20" spaceBefore="-3.0" textColor="black"/>
</stylesheet>
<images/>
<story>
<para>[[setLang(user.context_lang)]]</para>
<blockTable colWidths="2.5cm,6.0cm,2.5cm,2.5cm,2.5cm,2.5cm,2.5cm" style="BODY" repeatRows="1">
<tr noRowsplits="1">
<td>
<para style="TITLE_LEFT_ALIGN">
<font>CODE</font>
</para>
</td>
<td>
<para style="TITLES">ACCOUNT</para>
</td>
<td>
<para style="TITLE_LEFT_ALIGN">Q1</para>
</td>
<td>
<para style="TITLE_LEFT_ALIGN">Q2</para>
</td>
<td>
<para style="TITLE_LEFT_ALIGN">Q3</para>
</td>
<td>
<para style="TITLE_LEFT_ALIGN">Q4</para>
</td>
<td>
<para style="TITLE_LEFT_ALIGN">YTD</para>
</td>
</tr>
<tr>
<td>
<para style="TITLE_LEFT_ALIGN">[[ repeatIn(lines(data['form']), 'a') ]]
<font>[[ a['type']&lt;&gt;'view' and setTag('para','para',{'fontName':"Courier"}) or removeParentNode('font') ]]</font>
<i>[[a['label']==True and a['code'] or '' ]]</i>
</para>
</td>
<td>
<para style="TITLES">
<font>[[ ((a['total'] and not a['label']) and setTag('para','para',{'alignment':"RIGHT"}) or (a['type']&lt;&gt;'view' and setTag('para','para',{'fontName':"Courier"}))) or removeParentNode('font') ]]</font>
<font>[[ a['type']=='view' and a['name'].upper() or a['name'].title() ]]</font>
</para>
</td>
<td>
<para style="TITLE_LEFT_ALIGN">
<font>[[ a['type']&lt;&gt;'view' and setTag('para','para',{'fontName':"Courier"}) or removeParentNode('font') ]]</font>
<font>[[ (a['total']==True) and formatLang(a['bal1'] and a['bal1'] * a.get('change_sign') or 0.0, digits=2, grouping=True) or '']]</font>
</para>
</td>
<td>
<para style="TITLE_LEFT_ALIGN">
<font>[[ a['type']&lt;&gt;'view' and setTag('para','para',{'fontName':"Courier"}) or removeParentNode('font') ]]</font>
<font>[[ (a['total']==True) and formatLang(a['bal2'] and a['bal2'] * a.get('change_sign') or 0.0, digits=2, grouping=True) or '']]</font>
</para>
</td>
<td>
<para style="TITLE_LEFT_ALIGN">
<font>[[ a['type']&lt;&gt;'view' and setTag('para','para',{'fontName':"Courier"}) or removeParentNode('font') ]]</font>
<font>[[ (a['total']==True) and formatLang(a['bal3'] and a['bal3'] * a.get('change_sign') or 0.0, digits=2, grouping=True) or '']]</font>
</para>
</td>
<td>
<para style="TITLE_LEFT_ALIGN">
<font>[[ a['type']&lt;&gt;'view' and setTag('para','para',{'fontName':"Courier"}) or removeParentNode('font') ]]</font>
<font>[[ (a['total']==True) and formatLang(a['bal4'] and a['bal4'] * a.get('change_sign') or 0.0, digits=2, grouping=True) or '']]</font>
</para>
</td>
<td>
<para style="TITLE_LEFT_ALIGN">
<font>[[ a['type']&lt;&gt;'view' and setTag('para','para',{'fontName':"Courier"}) or removeParentNode('font') ]]</font>
<font>[[ (a['total']==True) and formatLang(a['bal5'] and a['bal5'] * a.get('change_sign') or 0.0, digits=2, grouping=True) or '']]</font>
</para>
</td>
</tr>
</blockTable>
</story>
</document>

737
account_financial_report/report/parser.py

@ -0,0 +1,737 @@
# -*- encoding: utf-8 -*-
###########################################################################
# Module Writen to OpenERP, Open Source Management Solution
# Copyright (C) OpenERP Venezuela (<http://openerp.com.ve>).
# All Rights Reserved
###############Credits######################################################
# Coded by: Humberto Arocha humberto@openerp.com.ve
# Angelica Barrios angelicaisabelb@gmail.com
# Jordi Esteve <jesteve@zikzakmedia.com>
# Javier Duran <javieredm@gmail.com>
# 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 <http://www.gnu.org/licenses/>.
##############################################################################
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 _
from osv import osv
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.
"""
afr_id = form['afr_id'] and type(form['afr_id']) in (list,tuple) and form['afr_id'][0] or form['afr_id']
if afr_id:
name = self.pool.get('afr').browse(self.cr, self.uid, afr_id).name
elif form['analytic_ledger'] and form['columns']=='four' and form['inf_type'] == 'BS':
name = _('Analytic Ledger')
elif form['inf_type'] == 'BS':
name = _('Balance Sheet')
elif form['inf_type'] == 'IS':
name = _('Income Statement')
return name
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 _('From ')+self.formatLang(form['date_from'], date=True)+ _(' to ')+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 _('From ')+self.formatLang(aux[0], date=True)+_(' to ')+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 get_company_accounts(self, company_id, acc='credit'):
rc_obj = self.pool.get('res.company')
if acc=='credit':
return [brw.id for brw in rc_obj.browse(self.cr, self.uid, company_id).credit_account_ids]
else:
return [brw.id for brw in rc_obj.browse(self.cr, self.uid, company_id).debit_account_ids]
def _get_analytic_ledger(self, account, ctx={}):
res = []
if account['type'] in ('other','liquidity','receivable','payable'):
#~ TODO: CUANDO EL PERIODO ESTE VACIO LLENARLO CON LOS PERIODOS DEL EJERCICIO
#~ FISCAL, SIN LOS PERIODOS ESPECIALES
periods = ', '.join([str(i) for i in ctx['periods']])
#~ periods = str(tuple(ctx['periods']))
where = """where aml.period_id in (%s) and aa.id = %s and aml.state <> 'draft'"""%(periods,account['id'])
sql_detalle = """select aml.id as id, aj.name as diario, aa.name as descripcion,
(select name from res_partner where aml.partner_id = id) as partner,
aa.code as cuenta, aml.name as name,
aml.ref as ref,
case when aml.debit is null then 0.00 else aml.debit end as debit,
case when aml.credit is null then 0.00 else aml.credit end as credit,
(select code from account_analytic_account where aml.analytic_account_id = id) as analitica,
aml.date as date, ap.name as periodo,
am.name as asiento
from account_move_line aml
inner join account_journal aj on aj.id = aml.journal_id
inner join account_account aa on aa.id = aml.account_id
inner join account_period ap on ap.id = aml.period_id
inner join account_move am on am.id = aml.move_id """ + where +\
""" order by date, am.name"""
self.cr.execute(sql_detalle)
resultat = self.cr.dictfetchall()
balance = account['balanceinit']
for det in resultat:
balance += det['debit'] - det['credit']
res.append({
'id': det['id'],
'date': det['date'],
'journal':det['diario'],
'partner':det['partner'],
'name':det['name'],
'entry':det['asiento'],
'ref': det['ref'],
'debit': det['debit'],
'credit': det['credit'],
'analytic': det['analitica'],
'period': det['periodo'],
'balance': balance,
})
return res
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)
"""
account_obj = self.pool.get('account.account')
period_obj = self.pool.get('account.period')
fiscalyear_obj = self.pool.get('account.fiscalyear')
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':
if not change_sign:
ids2.append([aa_brw.id,True, False,aa_brw])
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,aa_brw])
else:
if change_sign:
ids2.append(aa_brw.id)
else:
ids2.append([aa_brw.id,True,True,aa_brw])
return ids2
#############################################################################
# CONTEXT FOR ENDIND BALANCE #
#############################################################################
def _ctx_end(ctx):
ctx_end = ctx
ctx_end['filter'] = form.get('filter','all')
ctx_end['fiscalyear'] = fiscalyear.id
#~ ctx_end['periods'] = period_obj.search(self.cr, self.uid, [('fiscalyear_id','=',fiscalyear.id),('special','=',False)])
if ctx_end['filter'] not in ['bydate','none']:
special = self.special_period(form['periods'])
else:
special = False
if form['filter'] in ['byperiod', 'all']:
if special:
ctx_end['periods'] = period_obj.search(self.cr, self.uid, [('id','in',form['periods'] or ctx_end.get('periods',False))])
else:
ctx_end['periods'] = period_obj.search(self.cr, self.uid, [('id','in',form['periods'] or ctx_end.get('periods',False)),('special','=',False)])
if form['filter'] in ['bydate','all','none']:
ctx_end['date_from'] = form['date_from']
ctx_end['date_to'] = form['date_to']
return ctx_end.copy()
def missing_period(ctx_init):
ctx_init['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_init['periods'] = period_obj.search(self.cr, self.uid, [('fiscalyear_id','=',ctx_init['fiscalyear']),('date_stop','<',fiscalyear.date_start)])
return ctx_init
#############################################################################
# CONTEXT FOR INITIAL BALANCE #
#############################################################################
def _ctx_init(ctx):
ctx_init = self.context.copy()
ctx_init['filter'] = form.get('filter','all')
ctx_init['fiscalyear'] = fiscalyear.id
if form['filter'] in ['byperiod', 'all']:
ctx_init['periods'] = form['periods']
if not ctx_init['periods']:
ctx_init = missing_period(ctx_init.copy())
date_start = min([period.date_start for period in period_obj.browse(self.cr, self.uid, ctx_init['periods'])])
ctx_init['periods'] = period_obj.search(self.cr, self.uid, [('fiscalyear_id','=',fiscalyear.id),('date_stop','<=',date_start)])
elif form['filter'] in ['bydate']:
ctx_init['date_from'] = fiscalyear.date_start
ctx_init['date_to'] = form['date_from']
ctx_init['periods'] = period_obj.search(self.cr, self.uid, [('fiscalyear_id','=',fiscalyear.id),('date_stop','<=',ctx_init['date_to'])])
elif form['filter'] == 'none':
ctx_init['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_init['periods'])])
ctx_init['periods'] = period_obj.search(self.cr, self.uid, [('fiscalyear_id','=',fiscalyear.id),('date_start','<=',date_start),('special','=',True)])
return ctx_init.copy()
def z(n):
return abs(n) < 0.005 and 0.0 or n
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']
if form.has_key('account_list') and form['account_list']:
account_ids = form['account_list']
del form['account_list']
credit_account_ids = self.get_company_accounts(form['company_id'] and type(form['company_id']) in (list,tuple) and form['company_id'][0] or form['company_id'],'credit')
debit_account_ids = self.get_company_accounts(form['company_id'] and type(form['company_id']) in (list,tuple) and form['company_id'][0] or form['company_id'],'debit')
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 #
################################################################
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)
debit_account_ids = _get_children_and_consol(self.cr, self.uid, debit_account_ids, 100,self.context,change_sign=True)
credit_account_ids = list(set(credit_account_ids) - set(debit_account_ids))
#
# Generate the report lines (checking each account)
#
tot_check = False
if not form['periods']:
form['periods'] = period_obj.search(self.cr, self.uid, [('fiscalyear_id','=',fiscalyear.id),('special','=',False)],order='date_start asc')
if not form['periods']:
raise osv.except_osv(_('UserError'),_('The Selected Fiscal Year Does not have Regular Periods'))
if form['columns'] == 'qtr':
period_ids = period_obj.search(self.cr, self.uid, [('fiscalyear_id','=',fiscalyear.id),('special','=',False)],order='date_start asc')
a=0
l=[]
p=[]
for x in period_ids:
a+=1
if a<3:
l.append(x)
else:
l.append(x)
p.append(l)
l=[]
a=0
#~ period_ids = p
elif form['columns'] == 'thirteen':
period_ids = period_obj.search(self.cr, self.uid, [('fiscalyear_id','=',fiscalyear.id),('special','=',False)],order='date_start asc')
if form['columns'] == 'qtr':
tot_bal1 = 0.0
tot_bal2 = 0.0
tot_bal3 = 0.0
tot_bal4 = 0.0
tot_bal5 = 0.0
elif form['columns'] == 'thirteen':
tot_bal1 = 0.0
tot_bal2 = 0.0
tot_bal3 = 0.0
tot_bal4 = 0.0
tot_bal5 = 0.0
tot_bal6 = 0.0
tot_bal7 = 0.0
tot_bal8 = 0.0
tot_bal9 = 0.0
tot_bal10 = 0.0
tot_bal11 = 0.0
tot_bal12 = 0.0
tot_bal13 = 0.0
else:
ctx_init = _ctx_init(self.context.copy())
ctx_end = _ctx_end(self.context.copy())
tot_bin = 0.0
tot_deb = 0.0
tot_crd = 0.0
tot_ytd = 0.0
tot_eje = 0.0
res = {}
result_acc = []
tot = {}
for aa_id in account_ids:
id = aa_id[0]
#
# Check if we need to include this level
#
if not form['display_account_level'] or aa_id[3].level <= form['display_account_level']:
res = {
'id' : id,
'type' : aa_id[3].type,
'code' : aa_id[3].code,
'name' : (aa_id[2] and not aa_id[1]) and 'TOTAL %s'%(aa_id[3].name.upper()) or aa_id[3].name,
'parent_id' : aa_id[3].parent_id and aa_id[3].parent_id.id,
'level' : aa_id[3].level,
'label' : aa_id[1],
'total' : aa_id[2],
'change_sign' : credit_account_ids and (id in credit_account_ids and -1 or 1) or 1
}
if form['columns'] == 'qtr':
pn = 1
for p_id in p:
form['periods'] = p_id
ctx_init = _ctx_init(self.context.copy())
aa_brw_init = account_obj.browse(self.cr, self.uid, id, ctx_init)
ctx_end = _ctx_end(self.context.copy())
aa_brw_end = account_obj.browse(self.cr, self.uid, id, ctx_end)
if form['inf_type'] == 'IS':
d,c,b = map(z,[aa_brw_end.debit,aa_brw_end.credit,aa_brw_end.balance])
res.update({
'dbr%s'%pn: self.exchange(d),
'cdr%s'%pn: self.exchange(c),
'bal%s'%pn: self.exchange(b),
})
else:
i,d,c = map(z,[aa_brw_init.balance,aa_brw_end.debit,aa_brw_end.credit])
b = z(i+d-c)
res.update({
'dbr%s'%pn: self.exchange(d),
'cdr%s'%pn: self.exchange(c),
'bal%s'%pn: self.exchange(b),
})
pn +=1
form['periods'] = period_ids
ctx_init = _ctx_init(self.context.copy())
aa_brw_init = account_obj.browse(self.cr, self.uid, id, ctx_init)
ctx_end = _ctx_end(self.context.copy())
aa_brw_end = account_obj.browse(self.cr, self.uid, id, ctx_end)
if form['inf_type'] == 'IS':
d,c,b = map(z,[aa_brw_end.debit,aa_brw_end.credit,aa_brw_end.balance])
res.update({
'dbr5': self.exchange(d),
'cdr5': self.exchange(c),
'bal5': self.exchange(b),
})
else:
i,d,c = map(z,[aa_brw_init.balance,aa_brw_end.debit,aa_brw_end.credit])
b = z(i+d-c)
res.update({
'dbr5': self.exchange(d),
'cdr5': self.exchange(c),
'bal5': self.exchange(b),
})
elif form['columns'] == 'thirteen':
pn = 1
for p_id in period_ids:
form['periods'] = [p_id]
ctx_init = _ctx_init(self.context.copy())
aa_brw_init = account_obj.browse(self.cr, self.uid, id, ctx_init)
ctx_end = _ctx_end(self.context.copy())
aa_brw_end = account_obj.browse(self.cr, self.uid, id, ctx_end)
if form['inf_type'] == 'IS':
d,c,b = map(z,[aa_brw_end.debit,aa_brw_end.credit,aa_brw_end.balance])
res.update({
'dbr%s'%pn: self.exchange(d),
'cdr%s'%pn: self.exchange(c),
'bal%s'%pn: self.exchange(b),
})
else:
i,d,c = map(z,[aa_brw_init.balance,aa_brw_end.debit,aa_brw_end.credit])
b = z(i+d-c)
res.update({
'dbr%s'%pn: self.exchange(d),
'cdr%s'%pn: self.exchange(c),
'bal%s'%pn: self.exchange(b),
})
pn +=1
form['periods'] = period_ids
ctx_init = _ctx_init(self.context.copy())
aa_brw_init = account_obj.browse(self.cr, self.uid, id, ctx_init)
ctx_end = _ctx_end(self.context.copy())
aa_brw_end = account_obj.browse(self.cr, self.uid, id, ctx_end)
if form['inf_type'] == 'IS':
d,c,b = map(z,[aa_brw_end.debit,aa_brw_end.credit,aa_brw_end.balance])
res.update({
'dbr13': self.exchange(d),
'cdr13': self.exchange(c),
'bal13': self.exchange(b),
})
else:
i,d,c = map(z,[aa_brw_init.balance,aa_brw_end.debit,aa_brw_end.credit])
b = z(i+d-c)
res.update({
'dbr13': self.exchange(d),
'cdr13': self.exchange(c),
'bal13': self.exchange(b),
})
else:
aa_brw_init = account_obj.browse(self.cr, self.uid, id, ctx_init)
aa_brw_end = account_obj.browse(self.cr, self.uid, id, ctx_end)
i,d,c = map(z,[aa_brw_init.balance,aa_brw_end.debit,aa_brw_end.credit])
b = z(i+d-c)
res.update({
'balanceinit': self.exchange(i),
'debit': self.exchange(d),
'credit': self.exchange(c),
'ytd': self.exchange(d-c),
})
if form['inf_type'] == 'IS' and form['columns'] == 'one':
res.update({
'balance': self.exchange(d-c),
})
else:
res.update({
'balance': self.exchange(b),
})
#
# Check whether we must include this line in the report or not
#
to_include = False
if form['columns'] in ('thirteen', 'qtr'):
to_test = [False]
if form['display_account'] == 'mov' and aa_id[3].parent_id:
# Include accounts with movements
for x in range(pn-1):
to_test.append(res.get('dbr%s'%x,0.0) >= 0.005 and True or False)
to_test.append(res.get('cdr%s'%x,0.0) >= 0.005 and True or False)
if any(to_test):
to_include = True
elif form['display_account'] == 'bal' and aa_id[3].parent_id:
# Include accounts with balance
for x in range(pn-1):
to_test.append(res.get('bal%s'%x,0.0) >= 0.005 and True or False)
if any(to_test):
to_include = True
elif form['display_account'] == 'bal_mov' and aa_id[3].parent_id:
# Include accounts with balance or movements
for x in range(pn-1):
to_test.append(res.get('bal%s'%x,0.0) >= 0.005 and True or False)
to_test.append(res.get('dbr%s'%x,0.0) >= 0.005 and True or False)
to_test.append(res.get('cdr%s'%x,0.0) >= 0.005 and True or False)
if any(to_test):
to_include = True
else:
# Include all accounts
to_include = True
else:
if form['display_account'] == 'mov' and aa_id[3].parent_id:
# Include accounts with movements
if abs(d) >= 0.005 or abs(c) >= 0.005:
to_include = True
elif form['display_account'] == 'bal' and aa_id[3].parent_id:
# Include accounts with balance
if abs(b) >= 0.005:
to_include = True
elif form['display_account'] == 'bal_mov' and aa_id[3].parent_id:
# Include accounts with balance or movements
if abs(b) >= 0.005 or abs(d) >= 0.005 or abs(c) >= 0.005:
to_include = True
else:
# Include all accounts
to_include = True
#~ ANALYTIC LEDGER
if to_include and form['analytic_ledger'] and form['columns']=='four' and form['inf_type'] == 'BS' and res['type'] in ('other','liquidity','receivable','payable'):
res['mayor'] = self._get_analytic_ledger(res,ctx=ctx_end)
else:
res['mayor'] = []
if to_include:
result_acc.append(res)
#
# Check whether we must sumarize this line in the report or not
#
if form['tot_check'] and res['type'] == 'view' and res['level'] == 1 and (res['id'] not in tot):
if form['columns'] == 'qtr':
tot_check = True
tot[res['id']] = True
tot_bal1 += res.get('bal1',0.0)
tot_bal2 += res.get('bal2',0.0)
tot_bal3 += res.get('bal3',0.0)
tot_bal4 += res.get('bal4',0.0)
tot_bal5 += res.get('bal5',0.0)
elif form['columns'] == 'thirteen':
tot_check = True
tot[res['id']] = True
tot_bal1 += res.get('bal1',0.0)
tot_bal2 += res.get('bal2',0.0)
tot_bal3 += res.get('bal3',0.0)
tot_bal4 += res.get('bal4',0.0)
tot_bal5 += res.get('bal5',0.0)
tot_bal6 += res.get('bal6',0.0)
tot_bal7 += res.get('bal7',0.0)
tot_bal8 += res.get('bal8',0.0)
tot_bal9 += res.get('bal9',0.0)
tot_bal10 += res.get('bal10',0.0)
tot_bal11 += res.get('bal11',0.0)
tot_bal12 += res.get('bal12',0.0)
tot_bal13 += res.get('bal13',0.0)
else:
tot_check = True
tot[res['id']] = True
tot_bin += res['balanceinit']
tot_deb += res['debit']
tot_crd += res['credit']
tot_ytd += res['ytd']
tot_eje += res['balance']
if tot_check:
str_label = form['lab_str']
res2 = {
'type' : 'view',
'name': 'TOTAL %s'%(str_label),
'label': False,
'total': True,
}
if form['columns'] == 'qtr':
res2.update(dict(
bal1 = tot_bal1,
bal2 = tot_bal2,
bal3 = tot_bal3,
bal4 = tot_bal4,
bal5 = tot_bal5,))
elif form['columns'] == 'thirteen':
res2.update(dict(
bal1 = tot_bal1,
bal2 = tot_bal2,
bal3 = tot_bal3,
bal4 = tot_bal4,
bal5 = tot_bal5,
bal6 = tot_bal6,
bal7 = tot_bal7,
bal8 = tot_bal8,
bal9 = tot_bal9,
bal10 = tot_bal10,
bal11 = tot_bal11,
bal12 = tot_bal12,
bal13 = tot_bal13,))
else:
res2.update({
'balanceinit': tot_bin,
'debit': tot_deb,
'credit': tot_crd,
'ytd': tot_ytd,
'balance': tot_eje,
})
result_acc.append(res2)
return result_acc
report_sxw.report_sxw('report.afr.1cols',
'wizard.report',
'account_financial_report/report/balance_full.rml',
parser=account_balance,
header=False)
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.afr.4cols',
'wizard.report',
'account_financial_report/report/balance_full_4_cols.rml',
parser=account_balance,
header=False)
report_sxw.report_sxw('report.afr.analytic.ledger',
'wizard.report',
'account_financial_report/report/balance_full_4_cols_analytic_ledger.rml',
parser=account_balance,
header=False)
report_sxw.report_sxw('report.afr.5cols',
'wizard.report',
'account_financial_report/report/balance_full_5_cols.rml',
parser=account_balance,
header=False)
report_sxw.report_sxw('report.afr.qtrcols',
'wizard.report',
'account_financial_report/report/balance_full_qtr_cols.rml',
parser=account_balance,
header=False)
report_sxw.report_sxw('report.afr.13cols',
'wizard.report',
'account_financial_report/report/balance_full_13_cols.rml',
parser=account_balance,
header=False)

157
account_financial_report/view/account_financial_report_view.xml

@ -0,0 +1,157 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<record id="account_financial_report_view" model="ir.ui.view">
<field name="name">Account Financial Report (Template)</field>
<field name="model">afr</field>
<field name="type">form</field>
<field name="arch" type="xml">
<form string="Account Financial Report (Templates)">
<group colspan="4">
<field name="name" colspan="4"/>
</group>
<group colspan="4">
<group colspan="2">
<separator string="Company Info" colspan="4"/>
<field name="company_id" on_change='onchange_company_id(company_id)' colspan="4"/>
<field name="currency_id"
domain="[('company_id','=',company_id)]"
attrs="{'readonly':[('analytic_ledger','=',True)]}"
colspan="4"/>
</group>
<group colspan="2">
<separator string="Report Info" colspan="4"/>
<field
name="inf_type"
colspan="4"
on_change='onchange_inf_type(inf_type)'
/>
<field name="columns" on_change='onchange_columns(columns,fiscalyear_id,period_ids)' colspan="4"/>
<field name="analytic_ledger" colspan="4"
attrs="{'readonly':['|',('columns','!=','four'),('inf_type','!=','BS')],}"
on_change='onchange_analytic_ledger(company_id,analytic_ledger)'
/>
</group>
</group>
<group colspan='4'>
<group colspan="2">
<separator string="Accounts Info" colspan="4"/>
<field name="display_account" required="True" colspan="4"/>
<field name="display_account_level" required="True" colspan="4"/>
</group>
<group colspan="2">
<separator string="FiscalYear Info" colspan="4"/>
<field name="fiscalyear_id" on_change='onchange_columns(columns,fiscalyear_id,period_ids)' domain="[('company_id','=',company_id)]"/>
<newline/>
</group>
</group>
<group colspan='4'>
<group colspan="1">
<separator string="Accounts to Include" colspan="4"/>
<field name="account_ids" nolabel="1" colspan="4" domain="[('company_id','=',company_id)]">
<tree>
<field name='code'/>
<field name='name'/>
<field name='type'/>
<field name='level'/>
</tree>
</field>
</group>
<group colspan="1">
<separator string="Periods to Include" colspan="4"/>
<field name="period_ids"
colspan="4" nolabel="1"
domain="[('fiscalyear_id','=',fiscalyear_id),('special','=',False),('company_id','=',company_id)]"
attrs="{'readonly':[('columns','in',('qtr','thirteen'))],}"
>
<tree>
<field name='code'/>
<field name='name'/>
<field name='state'/>
</tree>
</field>
</group>
</group>
<group colspan='4'>
<separator string="Account's Sign Conventions" colspan="4"/>
<label string="Please check the [ Account's Sign on Reports ] Section in the Company"/>
</group>
<group colspan='4' col='4'>
<group colspan="2">
<separator string="Total" colspan="4"/>
<field name="tot_check" colspan="4"/>
<field name="lab_str" colspan="4" attrs="{'required':[('tot_check','=',True)], 'readonly':[('tot_check','=',False)],}" />
</group>
<group colspan="2">
<separator string="" colspan="4"/>
<!--
<button
name="print_report"
string="Print"
type="object"
icon='gtk-print'/>
<button
type='special'
special='cancel'
string='_Cancel'
icon='gtk-cancel'
/>
-->
</group>
</group>
</form>
</field>
</record>
<record id="account_financial_report_tree" model="ir.ui.view">
<field name="name">Account Financial Report (Template)</field>
<field name="model">afr</field>
<field name="type">tree</field>
<field name="arch" type="xml">
<tree string="Account Financial Report (Templates)">
<field name="name"/>
<field name="company_id"/>
<field name="currency_id"/>
<field name="inf_type"/>
<field name="columns"/>
<field name="display_account"/>
<field name="display_account_level" required="True" colspan="4"/>
<field name="fiscalyear_id"/>
<field name="tot_check" colspan="4"/>
<!--
<button name="print_report" string="Print" type="object"/>
-->
</tree>
</field>
</record>
<record model="ir.actions.act_window" id="account_financial_report_action">
<field name="name">Account Financial Report</field>
<field name="res_model">afr</field>
<field name="type">ir.actions.act_window</field>
<field name="view_type">form</field>
<field name="view_mode">tree,form</field>
<field name="help">Create your own Customized Account Financial Reports, in here, you will be able to create Templates for generating Two types of Reports: Balance Sheets and Income Statements, incluiding Analytic Ledgers. Besides, you can select within a set of choices to get better detailed report, be it that you ask it by one or several periods, by months (12 Months + YTD), or by quarters (4QRT's + YTD). Even you can get your reports in currencies other than the one set on your company.</field>
</record>
<menuitem
id="account_financial_report_menu"
name="Account Financial Report (Templates)"
parent="account.final_accounting_reports"
sequence="100"
groups="account_financial_report.group_afreport"
action="account_financial_report_action"/>
</data>
</openerp>

47
account_financial_report/view/company_view.xml

@ -0,0 +1,47 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<record model="ir.ui.view" id="view_company_credit_account_form">
<field name="name">res.company.form.inherit</field>
<field name="inherit_id" ref="base.view_company_form"/>
<field name="model">res.company</field>
<field name="type">form</field>
<field name="arch" type="xml">
<notebook position="inside">
<page string="Account's Sign on Reports" position="inside">
<group>
<group>
<separator string="Debitable Accounts" colspan="4"/>
<label string="A debitable account is one which grows in the debit and diminishes in the credit" colspan="4"/>
<label string="Keep sign on Reports for these accounts and children accounts that are within Accreditable Accounts" colspan="4"/>
<field name="debit_account_ids" nolabel="1" colspan ="4" domain="[('company_id.name','=',name),('company_id.partner_id','=',partner_id),]">
<tree>
<field name='code'/>
<field name='name'/>
<field name='type'/>
</tree>
</field>
</group>
<group>
<separator string="Accreditable Accounts" colspan="4"/>
<label string="An accreditable account is one which grows in the credit and diminishes in the debit" colspan="4"/>
<label string="Reverse sign on Reports for these accounts and children accounts that are within Debitable Accounts" colspan="4"/>
<field name="credit_account_ids" nolabel="1" colspan ="4" domain="[('company_id.name','=',name),('company_id.partner_id','=',partner_id),]">
<tree>
<field name='code'/>
<field name='name'/>
<field name='type'/>
</tree>
</field>
</group>
</group>
</page>
</notebook>
</field>
</record>
</data>
</openerp>

82
account_financial_report/view/report.xml

@ -0,0 +1,82 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<report
auto="False"
id="1_col_report"
menu="True"
model="wizard.report"
name="afr.1cols"
rml="account_financial_report/report/balance_full.rml"
string="Balance 1 Columna"
header="False"
/>
<report
auto="False"
id="2_col_report"
menu="True"
model="wizard.report"
name="afr.2cols"
rml="account_financial_report/report/balance_full_2_cols.rml"
string="Balance 2 Columnas"
header="False"
/>
<report
auto="False"
id="4_col_report"
menu="True"
model="wizard.report"
name="afr.4cols"
rml="account_financial_report/report/balance_full_4_cols.rml"
string="Balance 4 Columnas"
header="False"
/>
<report
auto="False"
id="analytic_ledger_report"
menu="True"
model="wizard.report"
name="afr.analytic.ledger"
rml="account_financial_report/report/balance_full_4_cols_analytic_ledger.rml"
string="Analytic Ledger"
header="False"
/>
<report
auto="False"
id="5_col_report"
menu="True"
model="wizard.report"
name="afr.5cols"
rml="account_financial_report/report/balance_full_5_cols.rml"
string="Balance 5 Columnas"
header="False"
/>
<report
auto="False"
id="qtr_col_report"
menu="True"
model="wizard.report"
name="afr.qtrcols"
rml="account_financial_report/report/balance_full_qtr_cols.rml"
string="Balance QTRs Columnas"
header="False"
/>
<report
auto="False"
id="13_col_report"
menu="True"
model="wizard.report"
name="afr.13cols"
rml="account_financial_report/report/balance_full_13_cols.rml"
string="Balance 13 Columnas"
header="False"
/>
</data>
</openerp>

129
account_financial_report/view/wizard.xml

@ -0,0 +1,129 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<record id="wizard_report_view" model="ir.ui.view">
<field name="name">Account Financial Report (Template)</field>
<field name="model">wizard.report</field>
<field name="type">form</field>
<field name="arch" type="xml">
<form string="Account Financial Report">
<group colspan="4">
<group colspan="2">
<separator string="Company Info" colspan="4"/>
<field name="company_id" on_change='onchange_company_id(company_id)' colspan="4"/>
<field name="currency_id"
domain="[('company_id','=',company_id)]"
attrs="{'readonly':[('analytic_ledger','=',True)]}"
colspan="4"/>
</group>
<group colspan="2">
<separator string="Report Info" colspan="4"/>
<field name="afr_id" on_change='onchange_afr_id(afr_id)' colspan="4"/>
<field
name="inf_type"
colspan="4"
on_change='onchange_inf_type(inf_type)'
/>
<field name="columns" on_change='onchange_columns(columns,fiscalyear,periods)' colspan="4"/>
<field name="analytic_ledger" colspan="4"
attrs="{'readonly':['|',('columns','!=','four'),('inf_type','!=','BS')],}"
on_change='onchange_analytic_ledger(company_id,analytic_ledger)'
/>
</group>
</group>
<group colspan='4'>
<group colspan="2">
<separator string="Accounts Info" colspan="4"/>
<field name="display_account" required="True" colspan="4"/>
<field name="display_account_level" required="True" colspan="4"/>
</group>
<group colspan="2">
<separator string="FiscalYear Info" colspan="4"/>
<field name="fiscalyear" on_change='onchange_columns(columns,fiscalyear,periods)' domain="[('company_id','=',company_id)]"/>
<newline/>
</group>
</group>
<group colspan='4'>
<group colspan="1">
<separator string="Accounts to Include" colspan="4"/>
<field name="account_list" nolabel="1" colspan="4" domain="[('company_id','=',company_id)]">
<tree>
<field name='code'/>
<field name='name'/>
<field name='type'/>
<field name='level'/>
</tree>
</field>
</group>
<group colspan="1">
<separator string="Periods to Include" colspan="4"/>
<field
name="periods"
colspan="4"
nolabel="1"
domain="[('fiscalyear_id','=',fiscalyear),('special','=',False),('company_id','=',company_id)]"
attrs="{'readonly':[('columns','in',('qtr','thirteen'))],}"
>
<tree>
<field name='code'/>
<field name='name'/>
<field name='state'/>
</tree>
</field>
</group>
</group>
<group colspan='4'>
<separator string="Account's Sign Conventions" colspan="4"/>
<label string="Please check the [ Account's Sign on Reports ] Section in the Company"/>
</group>
<group colspan='4' col='4'>
<group colspan="2">
<separator string="Total" colspan="4"/>
<field name="tot_check" colspan="4"/>
<field name="lab_str" colspan="4" attrs="{'required':[('tot_check','=',True)], 'readonly':[('tot_check','=',False)],}" />
</group>
<group colspan="2">
<separator string="" colspan="4"/>
<button
name="print_report"
string="Print"
type="object"
icon='gtk-print'/>
<button
type='special'
special='cancel'
string='_Cancel'
icon='gtk-cancel'
/>
</group>
</group>
</form>
</field>
</record>
<record id="action_wizard_report" model="ir.actions.act_window">
<field name="name">Account Financial Report (Multireports)</field>
<field name="res_model">wizard.report</field>
<field name="view_type">form</field>
<field name="view_mode">form</field>
<field name="view_id" ref="wizard_report_view"/>
<field name="target">new</field>
</record>
<menuitem
id="menu_wizard_report"
name="Account Financial Report (Multireports)"
parent="account.final_accounting_reports"
sequence="99"
groups="account_financial_report.group_afreport"
action="action_wizard_report"/>
</data>
</openerp>

6
account_financial_report/wizard/__init__.py

@ -25,8 +25,4 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>. # along with this program. If not, see <http://www.gnu.org/licenses/>.
############################################################################## ##############################################################################
import wizard_account_balance_4_report
import wizard_account_balance_2_report
import wizard_account_balance_report
import wizard

209
account_financial_report/wizard/account_report_wizard.xml

@ -1,209 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<record id="wizard_report_view" model="ir.ui.view">
<field name="name">Wizard Report Balance Four Columns</field>
<field name="model">wizard.report</field>
<field name="type">form</field>
<field name="arch" type="xml">
<form string="General Account Balance [ Initial | Debit | Credit | Balance ]">
<group>
<field name="company_id"/>
<group>
<field name="currency_id" domain="[('company_id','=',company_id)]"/>
</group>
<newline/>
<group colspan="4">
<separator string="Accounts to include" colspan="4"/>
<field name="account_list" nolabel="1" colspan="4" domain="[('company_id','=',company_id)]"/>
<field name="display_account" required="True"/>
<field name="display_account_level" required="True" />
</group>
<group colspan="4">
<separator string="Period" colspan="4"/>
<field name="fiscalyear"/>
<newline/>
<field name="filter" required="True"/>
<newline/>
<group attrs="{'invisible':[('filter','=','none')]}" colspan="4">
<group attrs="{'invisible':[('filter','=','byperiod')]}" colspan="4">
<separator string="Date Filter" colspan="4"/>
<field name="date_from"/>
<field name="date_to"/>
</group>
<group attrs="{'invisible':[('filter','=','bydate')]}" colspan="4">
<separator string="Filter on Periods" colspan="4"/>
<field name="periods" colspan="4" nolabel="1" domain="[('fiscalyear_id','=',fiscalyear)]"/>
</group>
</group>
</group>
<group colspan="4">
<separator string="Total" colspan="4"/>
<field name="tot_check"/>
<field name="lab_str"/>
<field name="inf_type"/>
<button name="print_report" string="Print" type="object"/>
</group>
</group>
</form>
</field>
</record>
<record id="action_wizard_report" model="ir.actions.act_window">
<field name="name">Reporte Balance Con Wizard</field>
<field name="res_model">wizard.report</field>
<field name="view_type">form</field>
<field name="view_mode">form</field>
<field name="view_id" ref="wizard_report_view"/>
<field name="target">new</field>
</record>
<menuitem
id="menu_wizard_report"
name="Reporte Balance 4 Columnas"
parent="account.final_accounting_reports"
sequence="99"
groups="account_financial_report.group_afreport"
action="action_wizard_report"/>
<record id="wizard_report_view2" model="ir.ui.view">
<field name="name">Wizard Report Balance Two Columns</field>
<field name="model">wizard.report.account.balance.gene.2</field>
<field name="type">form</field>
<field name="arch" type="xml">
<form string="General Account Balance [ Initial | Debit | Credit | Balance ]">
<group>
<field name="company_id"/>
<group>
<field name="currency_id" domain="[('company_id','=',company_id)]"/>
</group>
<newline/>
<group colspan="4">
<separator string="Accounts to include" colspan="4"/>
<field name="account_list" nolabel="1" colspan="4" domain="[('company_id','=',company_id)]"/>
<field name="display_account" required="True"/>
<field name="display_account_level" required="True" />
</group>
<group colspan="4">
<separator string="Period" colspan="4"/>
<field name="fiscalyear"/>
<newline/>
<field name="filter" required="True"/>
<newline/>
<group attrs="{'invisible':[('filter','=','none')]}" colspan="4">
<group attrs="{'invisible':[('filter','=','byperiod')]}" colspan="4">
<separator string="Date Filter" colspan="4"/>
<field name="date_from"/>
<field name="date_to"/>
</group>
<group attrs="{'invisible':[('filter','=','bydate')]}" colspan="4">
<separator string="Filter on Periods" colspan="4"/>
<field name="periods" colspan="4" nolabel="1" domain="[('fiscalyear_id','=',fiscalyear)]"/>
</group>
</group>
</group>
<group colspan="4">
<separator string="Total" colspan="4"/>
<field name="tot_check"/>
<field name="lab_str"/>
<field name="inf_type"/>
<button name="print_report" string="Print" type="object"/>
</group>
</group>
</form>
</field>
</record>
<record id="action_wizard_report2" model="ir.actions.act_window">
<field name="name">Reporte Balance Dos Columnas Con Wizard</field>
<field name="res_model">wizard.report.account.balance.gene.2</field>
<field name="view_type">form</field>
<field name="view_mode">form</field>
<field name="view_id" ref="wizard_report_view2"/>
<field name="target">new</field>
</record>
<menuitem
id="menu_wizard_report2"
name="Reporte Balance 2 Columnas"
parent="account.final_accounting_reports"
sequence="99"
groups="account_financial_report.group_afreport"
action="action_wizard_report2"/>
<record id="wizard_report_view3" model="ir.ui.view">
<field name="name">Wizard Report Balance</field>
<field name="model">wizard.report.account.balance.gene</field>
<field name="type">form</field>
<field name="arch" type="xml">
<form string="General Account Balance [ Initial | Debit | Credit | Balance ]">
<group>
<field name="company_id"/>
<group>
<field name="currency_id" domain="[('company_id','=',company_id)]"/>
</group>
<newline/>
<group colspan="4">
<separator string="Accounts to include" colspan="4"/>
<field name="account_list" nolabel="1" colspan="4" domain="[('company_id','=',company_id)]"/>
<field name="display_account" required="True"/>
<field name="display_account_level" required="True" />
</group>
<group colspan="4">
<separator string="Period" colspan="4"/>
<field name="fiscalyear"/>
<newline/>
<field name="filter" required="True"/>
<newline/>
<group attrs="{'invisible':[('filter','=','none')]}" colspan="4">
<group attrs="{'invisible':[('filter','=','byperiod')]}" colspan="4">
<separator string="Date Filter" colspan="4"/>
<field name="date_from"/>
<field name="date_to"/>
</group>
<group attrs="{'invisible':[('filter','=','bydate')]}" colspan="4">
<separator string="Filter on Periods" colspan="4"/>
<field name="periods" colspan="4" nolabel="1" domain="[('fiscalyear_id','=',fiscalyear)]"/>
</group>
</group>
</group>
<group colspan="4">
<separator string="Total" colspan="4"/>
<field name="tot_check"/>
<field name="lab_str"/>
<field name="inf_type"/>
<button name="print_report" string="Print" type="object"/>
</group>
</group>
</form>
</field>
</record>
<record id="action_wizard_report3" model="ir.actions.act_window">
<field name="name">Reporte Balance Dos Columnas Con Wizard</field>
<field name="res_model">wizard.report.account.balance.gene</field>
<field name="view_type">form</field>
<field name="view_mode">form</field>
<field name="view_id" ref="wizard_report_view3"/>
<field name="target">new</field>
</record>
<menuitem
id="menu_wizard_report3"
name="Reporte Balance "
parent="account.final_accounting_reports"
sequence="99"
groups="account_financial_report.group_afreport"
action="action_wizard_report3"/>
</data>
</openerp>

258
account_financial_report/wizard/wizard.py

@ -0,0 +1,258 @@
# -*- encoding: utf-8 -*-
###########################################################################
# Module Writen to OpenERP, Open Source Management Solution
# Copyright (C) OpenERP Venezuela (<http://openerp.com.ve>).
# All Rights Reserved
###############Credits######################################################
# Coded by: Humberto Arocha humberto@openerp.com.ve
# Angelica Barrios angelicaisabelb@gmail.com
# Jordi Esteve <jesteve@zikzakmedia.com>
# Javier Duran <javieredm@gmail.com>
# 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 <http://www.gnu.org/licenses/>.
##############################################################################
from osv import osv,fields
import pooler
import time
from tools.translate import _
class wizard_report(osv.osv_memory):
_name = "wizard.report"
_columns = {
'afr_id': fields.many2one('afr','Custom Report', help='If you have already set a Custom Report, Select it Here.'),
'company_id': fields.many2one('res.company','Company',required=True),
'currency_id': fields.many2one('res.currency', 'Currency', help="Currency at which this report will be expressed. If not selected will be used the one set in the company"),
'inf_type': fields.selection([('BS','Balance Sheet'),('IS','Income Statement')],'Type',required=True),
'columns': fields.selection([('one','End. Balance'),('two','Debit | Credit'), ('four','Initial | Debit | Credit | YTD'), ('five','Initial | Debit | Credit | Period | YTD'),('qtr',"4 QTR's | YTD"),('thirteen','12 Months | YTD')],'Columns',required=True),
'display_account': fields.selection([('all','All Accounts'),('bal', 'With Balance'),('mov','With movements'),('bal_mov','With Balance / Movements')],'Display accounts'),
'display_account_level': fields.integer('Up to level',help='Display accounts up to this level (0 to show all)'),
'account_list': fields.many2many ('account.account','rel_wizard_account','account_list','account_id','Root accounts',required=True),
'fiscalyear': fields.many2one('account.fiscalyear','Fiscal year',help='Fiscal Year for this report',required=True),
'periods': fields.many2many('account.period','rel_wizard_period','wizard_id','period_id','Periods',help='All periods in the fiscal year if empty'),
'analytic_ledger': fields.boolean('Analytic Ledger', help="Allows to Generate an Analytic Ledger for accounts with moves. Available when Balance Sheet and 'Initial | Debit | Credit | YTD' are selected"),
'tot_check': fields.boolean('Summarize?', help='Checking will add a new line at the end of the Report which will Summarize Columns in Report'),
'lab_str': fields.char('Description', help='Description for the Summary', size= 128),
#~ Deprecated fields
'filter': fields.selection([('bydate','By Date'),('byperiod','By Period'),('all','By Date and Period'),('none','No Filter')],'Date/Period Filter'),
'date_to': fields.date('End date'),
'date_from': fields.date('Start date'),
}
_defaults = {
'date_from': lambda *a: time.strftime('%Y-%m-%d'),
'date_to': lambda *a: time.strftime('%Y-%m-%d'),
'filter': lambda *a:'byperiod',
'display_account_level': lambda *a: 0,
'inf_type': lambda *a:'BS',
'company_id': lambda self,cr,uid,c: self.pool.get('res.company')._company_default_get(cr, uid, 'account.invoice', context=c),
'fiscalyear': lambda self, cr, uid, c: self.pool.get('account.fiscalyear').find(cr, uid),
'display_account': lambda *a:'bal_mov',
'columns': lambda *a:'five',
}
def onchange_inf_type(self,cr,uid,ids,inf_type,context=None):
if context is None:
context = {}
res = {'value':{}}
if inf_type != 'BS':
res['value'].update({'analytic_ledger':False})
return res
def onchange_columns(self,cr,uid,ids,columns,fiscalyear,periods,context=None):
if context is None:
context = {}
res = {'value':{}}
p_obj = self.pool.get("account.period")
all_periods = p_obj.search(cr,uid,[('fiscalyear_id','=',fiscalyear),('special','=',False)],context=context)
s = set(periods[0][2])
t = set(all_periods)
go = periods[0][2] and s.issubset(t) or False
if columns != 'four':
res['value'].update({'analytic_ledger':False})
if columns in ('qtr', 'thirteen'):
res['value'].update({'periods':all_periods})
else:
if go:
res['value'].update({'periods':periods})
else:
res['value'].update({'periods':[]})
return res
def onchange_analytic_ledger(self,cr,uid,ids,company_id,analytic_ledger,context=None):
if context is None:
context = {}
context['company_id']=company_id
res = {'value':{}}
cur_id = self.pool.get('res.company').browse(cr,uid,company_id,context=context).currency_id.id
res['value'].update({'currency_id':cur_id})
return res
def onchange_company_id(self,cr,uid,ids,company_id,context=None):
if context is None:
context = {}
context['company_id']=company_id
res = {'value':{}}
cur_id = self.pool.get('res.company').browse(cr,uid,company_id,context=context).currency_id.id
fy_id = self.pool.get('account.fiscalyear').find(cr, uid,context=context)
res['value'].update({'fiscalyear':fy_id})
res['value'].update({'currency_id':cur_id})
res['value'].update({'account_list':[]})
res['value'].update({'periods':[]})
res['value'].update({'afr_id':None})
return res
def onchange_afr_id(self,cr,uid,ids,afr_id,context=None):
if context is None:
context = {}
res = {'value':{}}
if not afr_id: return res
afr_brw = self.pool.get('afr').browse(cr,uid,afr_id,context=context)
res['value'].update({'currency_id':afr_brw.currency_id and afr_brw.currency_id.id or afr_brw.company_id.currency_id.id})
res['value'].update({'inf_type':afr_brw.inf_type or 'BS'})
res['value'].update({'columns':afr_brw.columns or 'five'})
res['value'].update({'display_account':afr_brw.display_account or 'bal_mov'})
res['value'].update({'display_account_level':afr_brw.display_account_level or 0})
res['value'].update({'fiscalyear':afr_brw.fiscalyear_id and afr_brw.fiscalyear_id.id})
res['value'].update({'account_list':[acc.id for acc in afr_brw.account_ids]})
res['value'].update({'periods':[p.id for p in afr_brw.period_ids]})
res['value'].update({'analytic_ledger':afr_brw.analytic_ledger or False})
res['value'].update({'tot_check':afr_brw.tot_check or False})
res['value'].update({'lab_str':afr_brw.lab_str or _('Write a Description for your Summary Total')})
return res
def _get_defaults(self, cr, uid, data, context=None):
if context is None:
context = {}
user = pooler.get_pool(cr.dbname).get('res.users').browse(cr, uid, uid, context=context)
if user.company_id:
company_id = user.company_id.id
else:
company_id = pooler.get_pool(cr.dbname).get('res.company').search(cr, uid, [('parent_id', '=', False)])[0]
data['form']['company_id'] = company_id
fiscalyear_obj = pooler.get_pool(cr.dbname).get('account.fiscalyear')
data['form']['fiscalyear'] = fiscalyear_obj.find(cr, uid)
data['form']['context'] = context
return data['form']
def _check_state(self, cr, uid, data, context=None):
if context is None:
context = {}
if data['form']['filter'] == 'bydate':
self._check_date(cr, uid, data, context)
return data['form']
def _check_date(self, cr, uid, data, context=None):
if context is None:
context = {}
if data['form']['date_from'] > data['form']['date_to']:
raise osv.except_osv(_('Error !'),('La fecha final debe ser mayor a la inicial'))
sql = """SELECT f.id, f.date_start, f.date_stop
FROM account_fiscalyear f
WHERE '%s' = f.id """%(data['form']['fiscalyear'])
cr.execute(sql)
res = cr.dictfetchall()
if res:
if (data['form']['date_to'] > res[0]['date_stop'] or data['form']['date_from'] < res[0]['date_start']):
raise osv.except_osv(_('UserError'),'Las fechas deben estar entre %s y %s' % (res[0]['date_start'], res[0]['date_stop']))
else:
return 'report'
else:
raise osv.except_osv(_('UserError'),'No existe periodo fiscal')
def period_span(self, cr, uid, ids, fy_id, context=None):
if context is None:
context = {}
ap_obj = self.pool.get('account.period')
fy_id = fy_id and type(fy_id) in (list,tuple) and fy_id[0] or fy_id
if not ids:
#~ No hay periodos
return ap_obj.search(cr, uid, [('fiscalyear_id','=',fy_id),('special','=',False)],order='date_start asc')
ap_brws = ap_obj.browse(cr, uid, ids, context=context)
date_start = min([period.date_start for period in ap_brws])
date_stop = max([period.date_stop for period in ap_brws])
return ap_obj.search(cr, uid, [('fiscalyear_id','=',fy_id),('special','=',False),('date_start','>=',date_start),('date_stop','<=',date_stop)],order='date_start asc')
def print_report(self, cr, uid, ids, data, context=None):
if context is None:
context = {}
data = {}
data['ids'] = context.get('active_ids', [])
data['model'] = context.get('active_model', 'ir.ui.menu')
data['form'] = self.read(cr, uid, ids[0])
if data['form']['filter'] == 'byperiod':
del data['form']['date_from']
del data['form']['date_to']
data['form']['periods'] = self.period_span(cr, uid, data['form']['periods'], data['form']['fiscalyear'])
elif data['form']['filter'] == 'bydate':
self._check_date(cr, uid, data)
del data['form']['periods']
elif data['form']['filter'] == 'none':
del data['form']['date_from']
del data['form']['date_to']
del data['form']['periods']
else:
self._check_date(cr, uid, data)
lis2 = str(data['form']['periods']).replace("[","(").replace("]",")")
sqlmm = """select min(p.date_start) as inicio, max(p.date_stop) as fin
from account_period p
where p.id in %s"""%lis2
cr.execute(sqlmm)
minmax = cr.dictfetchall()
if minmax:
if (data['form']['date_to'] < minmax[0]['inicio']) or (data['form']['date_from'] > minmax[0]['fin']):
raise osv.except_osv(_('Error !'),_('La interseccion entre el periodo y fecha es vacio'))
if data['form']['columns'] == 'one':
name = 'afr.1cols'
if data['form']['columns'] == 'two':
name = 'afr.2cols'
if data['form']['columns'] == 'four':
if data['form']['analytic_ledger'] and data['form']['inf_type'] == 'BS':
name = 'afr.analytic.ledger'
else:
name = 'afr.4cols'
if data['form']['columns'] == 'five':
name = 'afr.5cols'
if data['form']['columns'] == 'qtr':
name = 'afr.qtrcols'
if data['form']['columns'] == 'thirteen':
name = 'afr.13cols'
return {'type': 'ir.actions.report.xml', 'report_name': name, 'datas': data}
wizard_report()

150
account_financial_report/wizard/wizard_account_balance_2_report.py

@ -1,150 +0,0 @@
# -*- encoding: utf-8 -*-
###########################################################################
# Module Writen to OpenERP, Open Source Management Solution
# Copyright (C) OpenERP Venezuela (<http://www.vauxoo.com>).
# All Rights Reserved
###############Credits######################################################
# Coded by: Humberto Arocha humberto@openerp.com.ve
# Angelica Barrios angelicaisabelb@gmail.com
# Jordi Esteve <jesteve@zikzakmedia.com>
# Javier Duran <javieredm@gmail.com>
# Planified by: Humberto Arocha
# Finance by: HELADOS GILDA, C.A. http://www.heladosgilda.com.ve
# Audited by: Humberto Arocha hbto@vauxoo.com
#############################################################################
# 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 <http://www.gnu.org/licenses/>.
##############################################################################
from osv import osv,fields
import pooler
import time
from tools.translate import _
class wizard_account_balance_gene_2(osv.osv_memory):
_name = "wizard.report.account.balance.gene.2"
_columns = {
'company_id': fields.many2one('res.company','Company',required=True),
'account_list': fields.many2many ('account.account','rel_wizard_account','account_list','account_id','Root accounts',required=True),
'filter': fields.selection([('bydate','By Date'),('byperiod','By Period'),('all','By Date and Period'),('none','No Filter')],'Date/Period Filter'),
'fiscalyear': fields.many2one('account.fiscalyear','Fiscal year',help='Keep empty to use all open fiscal years to compute the balance',required=True),
'periods': fields.many2many('account.period','rel_wizard_period','wizard_id','period_id','Periods',help='All periods in the fiscal year if empty'),
'display_account': fields.selection([('all','All'),('con_balance', 'With balance'),('con_movimiento','With movements')],'Display accounts'),
'display_account_level': fields.integer('Up to level',help='Display accounts up to this level (0 to show all)'),
'date_from': fields.date('Start date'),
'date_to': fields.date('End date'),
'tot_check': fields.boolean('Show Total'),
'lab_str': fields.char('Description', size= 128),
'inf_type': fields.selection([('bgen','Balance General'),('bcom','Balance Comprobacion'),('edogp','Estado Ganancias y Perdidas'),('bdl','Diario Legal')],'Tipo Informe',required=True),
#~ 'type_report': fields.selection([('un_col','Una Columna'),('dos_col','Dos Columnas'),('cuatro_col','Cuatro Columnas')],'Tipo Informe',required=True),
'currency_id': fields.many2one('res.currency', 'Secondary Currency', help="Forces all values for this report to be expressed in this secondary currency."),
}
_defaults = {
'date_from': lambda *a: time.strftime('%Y-%m-%d'),
'date_to': lambda *a: time.strftime('%Y-%m-%d'),
'filter': lambda *a:'byperiod',
'display_account_level': lambda *a: 0,
'inf_type': lambda *a:'bcom',
'company_id': lambda self,cr,uid,c: self.pool.get('res.company')._company_default_get(cr, uid, 'account.invoice', context=c),
'fiscalyear': lambda self, cr, uid, c: self.pool.get('account.fiscalyear').find(cr, uid),
'display_account': lambda *a:'con_movimiento',
}
def onchange_filter(self,cr,uid,ids,fiscalyear,filters,context=None):
if context is None:
context = {}
res = {}
if filters in ("bydate","all"):
fisy = self.pool.get("account.fiscalyear")
fis_actual = fisy.browse(cr,uid,fiscalyear,context=context)
res = {'value':{'date_from': fis_actual.date_start, 'date_to': fis_actual.date_stop}}
return res
def _get_defaults(self, cr, uid, data, context=None):
if context is None:
context = {}
user = pooler.get_pool(cr.dbname).get('res.users').browse(cr, uid, uid, context=context)
if user.company_id:
company_id = user.company_id.id
else:
company_id = pooler.get_pool(cr.dbname).get('res.company').search(cr, uid, [('parent_id', '=', False)])[0]
data['form']['company_id'] = company_id
fiscalyear_obj = pooler.get_pool(cr.dbname).get('account.fiscalyear')
data['form']['fiscalyear'] = fiscalyear_obj.find(cr, uid)
data['form']['context'] = context
return data['form']
def _check_state(self, cr, uid, data, context=None):
if context is None:
context = {}
if data['form']['filter'] == 'bydate':
self._check_date(cr, uid, data, context)
return data['form']
def _check_date(self, cr, uid, data, context=None):
if context is None:
context = {}
if data['form']['date_from'] > data['form']['date_to']:
raise osv.except_osv(_('Error !'),('La fecha final debe ser mayor a la inicial'))
sql = """SELECT f.id, f.date_start, f.date_stop
FROM account_fiscalyear f
WHERE '%s' = f.id """%(data['form']['fiscalyear'])
cr.execute(sql)
res = cr.dictfetchall()
if res:
if (data['form']['date_to'] > res[0]['date_stop'] or data['form']['date_from'] < res[0]['date_start']):
raise osv.except_osv(_('UserError'),'Las fechas deben estar entre %s y %s' % (res[0]['date_start'], res[0]['date_stop']))
else:
return 'report'
else:
raise osv.except_osv(_('UserError'),'No existe periodo fiscal')
def print_report(self, cr, uid, ids,data, context=None):
if context is None:
context = {}
data = {}
data['ids'] = context.get('active_ids', [])
data['model'] = context.get('active_model', 'ir.ui.menu')
data['form'] = self.read(cr, uid, ids[0])
if data['form']['filter'] == 'byperiod':
del data['form']['date_from']
del data['form']['date_to']
elif data['form']['filter'] == 'bydate':
self._check_date(cr, uid, data)
del data['form']['periods']
elif data['form']['filter'] == 'none':
del data['form']['date_from']
del data['form']['date_to']
del data['form']['periods']
else:
self._check_date(cr, uid, data)
lis2 = str(data['form']['periods']).replace("[","(").replace("]",")")
sqlmm = """select min(p.date_start) as inicio, max(p.date_stop) as fin
from account_period p
where p.id in %s"""%lis2
cr.execute(sqlmm)
minmax = cr.dictfetchall()
if minmax:
if (data['form']['date_to'] < minmax[0]['inicio']) or (data['form']['date_from'] > minmax[0]['fin']):
raise osv.except_osv(_('Error !'),_('La intersepcion entre el periodo y fecha es vacio'))
return {'type': 'ir.actions.report.xml', 'report_name': 'account.account.balance.gene.2', 'datas': data}
wizard_account_balance_gene_2()

150
account_financial_report/wizard/wizard_account_balance_4_report.py

@ -1,150 +0,0 @@
# -*- encoding: utf-8 -*-
###########################################################################
# Module Writen to OpenERP, Open Source Management Solution
# Copyright (C) OpenERP Venezuela (<http://openerp.com.ve>).
# All Rights Reserved
###############Credits######################################################
# Coded by: Humberto Arocha humberto@openerp.com.ve
# Angelica Barrios angelicaisabelb@gmail.com
# Jordi Esteve <jesteve@zikzakmedia.com>
# Javier Duran <javieredm@gmail.com>
# 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 <http://www.gnu.org/licenses/>.
##############################################################################
from osv import osv,fields
import pooler
import time
from tools.translate import _
class wizard_report(osv.osv_memory):
_name = "wizard.report"
_columns = {
'company_id': fields.many2one('res.company','Company',required=True),
'account_list': fields.many2many ('account.account','rel_wizard_account','account_list','account_id','Root accounts',required=True),
'filter': fields.selection([('bydate','By Date'),('byperiod','By Period'),('all','By Date and Period'),('none','No Filter')],'Date/Period Filter'),
'fiscalyear': fields.many2one('account.fiscalyear','Fiscal year',help='Keep empty to use all open fiscal years to compute the balance',required=True),
'periods': fields.many2many('account.period','rel_wizard_period','wizard_id','period_id','Periods',help='All periods in the fiscal year if empty'),
'display_account': fields.selection([('all','All'),('con_balance', 'With balance'),('con_movimiento','With movements')],'Display accounts'),
'display_account_level': fields.integer('Up to level',help='Display accounts up to this level (0 to show all)'),
'date_from': fields.date('Start date'),
'date_to': fields.date('End date'),
'tot_check': fields.boolean('Show Total'),
'lab_str': fields.char('Description', size= 128),
'inf_type': fields.selection([('bgen','Balance General'),('bcom','Balance Comprobacion'),('edogp','Estado Ganancias y Perdidas'),('bml','Libro Mayor Legal')],'Tipo Informe',required=True),
#~ 'type_report': fields.selection([('un_col','Una Columna'),('dos_col','Dos Columnas'),('cuatro_col','Cuatro Columnas')],'Tipo Informe',required=True),
'currency_id': fields.many2one('res.currency', 'Secondary Currency', help="Forces all values for this report to be expressed in this secondary currency."),
}
_defaults = {
'date_from': lambda *a: time.strftime('%Y-%m-%d'),
'date_to': lambda *a: time.strftime('%Y-%m-%d'),
'filter': lambda *a:'byperiod',
'display_account_level': lambda *a: 0,
'inf_type': lambda *a:'bcom',
'company_id': lambda self,cr,uid,c: self.pool.get('res.company')._company_default_get(cr, uid, 'account.invoice', context=c),
'fiscalyear': lambda self, cr, uid, c: self.pool.get('account.fiscalyear').find(cr, uid),
'display_account': lambda *a:'con_movimiento',
}
def onchange_filter(self,cr,uid,ids,fiscalyear,filters,context=None):
if context is None:
context = {}
res = {}
if filters in ("bydate","all"):
fisy = self.pool.get("account.fiscalyear")
fis_actual = fisy.browse(cr,uid,fiscalyear,context=context)
res = {'value':{'date_from': fis_actual.date_start, 'date_to': fis_actual.date_stop}}
return res
def _get_defaults(self, cr, uid, data, context=None):
if context is None:
context = {}
user = pooler.get_pool(cr.dbname).get('res.users').browse(cr, uid, uid, context=context)
if user.company_id:
company_id = user.company_id.id
else:
company_id = pooler.get_pool(cr.dbname).get('res.company').search(cr, uid, [('parent_id', '=', False)])[0]
data['form']['company_id'] = company_id
fiscalyear_obj = pooler.get_pool(cr.dbname).get('account.fiscalyear')
data['form']['fiscalyear'] = fiscalyear_obj.find(cr, uid)
data['form']['context'] = context
return data['form']
def _check_state(self, cr, uid, data, context=None):
if context is None:
context = {}
if data['form']['filter'] == 'bydate':
self._check_date(cr, uid, data, context)
return data['form']
def _check_date(self, cr, uid, data, context=None):
if context is None:
context = {}
if data['form']['date_from'] > data['form']['date_to']:
raise osv.except_osv(_('Error !'),('La fecha final debe ser mayor a la inicial'))
sql = """SELECT f.id, f.date_start, f.date_stop
FROM account_fiscalyear f
WHERE '%s' = f.id """%(data['form']['fiscalyear'])
cr.execute(sql)
res = cr.dictfetchall()
if res:
if (data['form']['date_to'] > res[0]['date_stop'] or data['form']['date_from'] < res[0]['date_start']):
raise osv.except_osv(_('UserError'),'Las fechas deben estar entre %s y %s' % (res[0]['date_start'], res[0]['date_stop']))
else:
return 'report'
else:
raise osv.except_osv(_('UserError'),'No existe periodo fiscal')
def print_report(self, cr, uid, ids,data, context=None):
if context is None:
context = {}
data = {}
data['ids'] = context.get('active_ids', [])
data['model'] = context.get('active_model', 'ir.ui.menu')
data['form'] = self.read(cr, uid, ids[0])
if data['form']['filter'] == 'byperiod':
del data['form']['date_from']
del data['form']['date_to']
elif data['form']['filter'] == 'bydate':
self._check_date(cr, uid, data)
del data['form']['periods']
elif data['form']['filter'] == 'none':
del data['form']['date_from']
del data['form']['date_to']
del data['form']['periods']
else:
self._check_date(cr, uid, data)
lis2 = str(data['form']['periods']).replace("[","(").replace("]",")")
sqlmm = """select min(p.date_start) as inicio, max(p.date_stop) as fin
from account_period p
where p.id in %s"""%lis2
cr.execute(sqlmm)
minmax = cr.dictfetchall()
if minmax:
if (data['form']['date_to'] < minmax[0]['inicio']) or (data['form']['date_from'] > minmax[0]['fin']):
raise osv.except_osv(_('Error !'),_('La intersepcion entre el periodo y fecha es vacio'))
return {'type': 'ir.actions.report.xml', 'report_name': 'wizard.report.reporte', 'datas': data}
wizard_report()

150
account_financial_report/wizard/wizard_account_balance_report.py

@ -1,150 +0,0 @@
# -*- encoding: utf-8 -*-
###########################################################################
# Module Writen to OpenERP, Open Source Management Solution
# Copyright (C) OpenERP Venezuela (<http://openerp.com.ve>).
# All Rights Reserved
###############Credits######################################################
# Coded by: Humberto Arocha humberto@openerp.com.ve
# Angelica Barrios angelicaisabelb@gmail.com
# Jordi Esteve <jesteve@zikzakmedia.com>
# Javier Duran <javieredm@gmail.com>
# 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 <http://www.gnu.org/licenses/>.
##############################################################################
from osv import osv,fields
import pooler
import time
from tools.translate import _
class wizard_account_balance_gene(osv.osv_memory):
_name = "wizard.report.account.balance.gene"
_columns = {
'company_id': fields.many2one('res.company','Company',required=True),
'account_list': fields.many2many ('account.account','rel_wizard_account','account_list','account_id','Root accounts',required=True),
'filter': fields.selection([('bydate','By Date'),('byperiod','By Period'),('all','By Date and Period'),('none','No Filter')],'Date/Period Filter'),
'fiscalyear': fields.many2one('account.fiscalyear','Fiscal year',help='Keep empty to use all open fiscal years to compute the balance',required=True),
'periods': fields.many2many('account.period','rel_wizard_period','wizard_id','period_id','Periods',help='All periods in the fiscal year if empty'),
'display_account': fields.selection([('all','All'),('con_balance', 'With balance'),('con_movimiento','With movements')],'Display accounts'),
'display_account_level': fields.integer('Up to level',help='Display accounts up to this level (0 to show all)'),
'date_from': fields.date('Start date'),
'date_to': fields.date('End date'),
'tot_check': fields.boolean('Show Total'),
'lab_str': fields.char('Description', size= 128),
'inf_type': fields.selection([('bgen','Balance General'),('bcom','Balance Comprobacion'),('edogp','Estado Ganancias y Perdidas')],'Tipo Informe',required=True),
#~ 'type_report': fields.selection([('un_col','Una Columna'),('dos_col','Dos Columnas'),('cuatro_col','Cuatro Columnas')],'Tipo Informe',required=True),
'currency_id': fields.many2one('res.currency', 'Secondary Currency', help="Forces all values for this report to be expressed in this secondary currency."),
}
_defaults = {
'date_from': lambda *a: time.strftime('%Y-%m-%d'),
'date_to': lambda *a: time.strftime('%Y-%m-%d'),
'filter': lambda *a:'byperiod',
'display_account_level': lambda *a: 0,
'inf_type': lambda *a:'bcom',
'company_id': lambda self,cr,uid,c: self.pool.get('res.company')._company_default_get(cr, uid, 'account.invoice', context=c),
'fiscalyear': lambda self, cr, uid, c: self.pool.get('account.fiscalyear').find(cr, uid),
'display_account': lambda *a:'con_movimiento',
}
def onchange_filter(self,cr,uid,ids,fiscalyear,filters,context=None):
if context is None:
context = {}
res = {}
if filters in ("bydate","all"):
fisy = self.pool.get("account.fiscalyear")
fis_actual = fisy.browse(cr,uid,fiscalyear,context=context)
res = {'value':{'date_from': fis_actual.date_start, 'date_to': fis_actual.date_stop}}
return res
def _get_defaults(self, cr, uid, data, context=None):
if context is None:
context = {}
user = pooler.get_pool(cr.dbname).get('res.users').browse(cr, uid, uid, context=context)
if user.company_id:
company_id = user.company_id.id
else:
company_id = pooler.get_pool(cr.dbname).get('res.company').search(cr, uid, [('parent_id', '=', False)])[0]
data['form']['company_id'] = company_id
fiscalyear_obj = pooler.get_pool(cr.dbname).get('account.fiscalyear')
data['form']['fiscalyear'] = fiscalyear_obj.find(cr, uid)
data['form']['context'] = context
return data['form']
def _check_state(self, cr, uid, data, context=None):
if context is None:
context = {}
if data['form']['filter'] == 'bydate':
self._check_date(cr, uid, data, context)
return data['form']
def _check_date(self, cr, uid, data, context=None):
if context is None:
context = {}
if data['form']['date_from'] > data['form']['date_to']:
raise osv.except_osv(_('Error !'),('La fecha final debe ser mayor a la inicial'))
sql = """SELECT f.id, f.date_start, f.date_stop
FROM account_fiscalyear f
WHERE '%s' = f.id """%(data['form']['fiscalyear'])
cr.execute(sql)
res = cr.dictfetchall()
if res:
if (data['form']['date_to'] > res[0]['date_stop'] or data['form']['date_from'] < res[0]['date_start']):
raise osv.except_osv(_('UserError'),'Las fechas deben estar entre %s y %s' % (res[0]['date_start'], res[0]['date_stop']))
else:
return 'report'
else:
raise osv.except_osv(_('UserError'),'No existe periodo fiscal')
def print_report(self, cr, uid, ids,data, context=None):
if context is None:
context = {}
data = {}
data['ids'] = context.get('active_ids', [])
data['model'] = context.get('active_model', 'ir.ui.menu')
data['form'] = self.read(cr, uid, ids[0])
if data['form']['filter'] == 'byperiod':
del data['form']['date_from']
del data['form']['date_to']
elif data['form']['filter'] == 'bydate':
self._check_date(cr, uid, data)
del data['form']['periods']
elif data['form']['filter'] == 'none':
del data['form']['date_from']
del data['form']['date_to']
del data['form']['periods']
else:
self._check_date(cr, uid, data)
lis2 = str(data['form']['periods']).replace("[","(").replace("]",")")
sqlmm = """select min(p.date_start) as inicio, max(p.date_stop) as fin
from account_period p
where p.id in %s"""%lis2
cr.execute(sqlmm)
minmax = cr.dictfetchall()
if minmax:
if (data['form']['date_to'] < minmax[0]['inicio']) or (data['form']['date_from'] > minmax[0]['fin']):
raise osv.except_osv(_('Error !'),_('La intersepcion entre el periodo y fecha es vacio'))
return {'type': 'ir.actions.report.xml', 'report_name': 'account.account.balance.gene', 'datas': data}
wizard_account_balance_gene()

36
account_financial_report/wizard/wizard_report_report.xml

@ -1,36 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<report
auto="False"
id="wizard_report_reporte_4_col"
menu="True"
model="wizard.report"
name="wizard.report.reporte"
rml="account_financial_report/report/balance_full_4_cols.rml"
string="Balance de Comprobacion Wizard 4 Columnas"
header="False"
/>
<report
auto="False"
id="wizard_report_reporte_2_col"
menu="True"
model="wizard.report.account.balance.gene.2"
name="account.account.balance.gene.2"
rml="account_financial_report/report/balance_full_2_cols.rml"
string="Balance de Comprobacion Wizard 2 Columnas"
header="False"
/>
<report
auto="False"
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"
/>
</data>
</openerp>
Loading…
Cancel
Save