Browse Source

[MERGE] from lp:~vauxoo/account-financial-report/7.0-mig_account_financial_report

pull/7/merge
Luis Escobar 12 years ago
parent
commit
7f37153f0f
  1. 34
      account_financial_report/__openerp__.py
  2. 18
      account_financial_report/model/account_financial_report.py
  3. 5
      account_financial_report/model/res_company.py
  4. 193
      account_financial_report/report/parser.py
  5. 23
      account_financial_report/view/account_view.xml

34
account_financial_report/__openerp__.py

@ -1,9 +1,8 @@
# -*- encoding: utf-8 -*-
###########################################################################
# Module Writen to OpenERP, Open Source Management Solution
# Copyright (C) OpenERP Venezuela (<http://openerp.com.ve>).
# All Rights Reserved
###############Credits######################################################
# Credits######################################################
# Coded by: Humberto Arocha humberto@openerp.com.ve
# Angelica Barrios angelicaisabelb@gmail.com
# Jordi Esteve <jesteve@zikzakmedia.com>
@ -29,24 +28,35 @@
"version": "2.0",
"author": "Vauxoo",
"website": "http://www.vauxoo.com",
"depends" : ["base","account"],
"category" : "Localisation/Accounting",
"depends": ["base",
"account"
],
"category": "Accounting",
"description": """
This modules is a multiporpuse report generator.
Multiporpuse Accounting report generator.
=========================================
From the wizard you will be asked to provide information needed to create your report.
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.
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" : [],
"demo_xml" : [],
"update_xml" : [
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""",
"data": [
"security/security.xml",
"security/ir.model.access.csv",
"view/report.xml",
"view/wizard.xml",
# "view/account_view.xml",
"view/company_view.xml",
"view/account_financial_report_view.xml",
],

18
account_financial_report/model/account_financial_report.py

@ -3,7 +3,7 @@
# Module Writen to OpenERP, Open Source Management Solution
# Copyright (C) OpenERP Venezuela (<http://openerp.com.ve>).
# All Rights Reserved
###############Credits######################################################
# Credits######################################################
# Coded by: Humberto Arocha humberto@openerp.com.ve
# Angelica Barrios angelicaisabelb@gmail.com
# Jordi Esteve <jesteve@zikzakmedia.com>
@ -31,6 +31,7 @@ import pooler
import time
from tools.translate import _
class account_financial_report(osv.osv):
_name = "afr"
@ -75,7 +76,8 @@ class account_financial_report(osv.osv):
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)
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
@ -101,7 +103,8 @@ class account_financial_report(osv.osv):
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)
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': []})
@ -112,7 +115,8 @@ class account_financial_report(osv.osv):
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
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
@ -125,8 +129,10 @@ class account_financial_report(osv.osv):
if not company_id:
return res
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)
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': []})

5
account_financial_report/model/res_company.py

@ -4,7 +4,7 @@
# Module Writen to OpenERP, Open Source Management Solution
# Copyright (C) OpenERP Venezuela (<http://openerp.com.ve>).
# All Rights Reserved
###############Credits######################################################
# Credits######################################################
# Coded by: Humberto Arocha <hbto@vauxoo.com>
# Planified by: Rafael Silva <rsilvam@vauxoo.com>
# Audited by: Nhomar Hernandez <nhomar@vauxoo.com>
@ -21,12 +21,13 @@
#
# 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 = {

193
account_financial_report/report/parser.py

@ -3,7 +3,7 @@
# Module Writen to OpenERP, Open Source Management Solution
# Copyright (C) OpenERP Venezuela (<http://openerp.com.ve>).
# All Rights Reserved
###############Credits######################################################
# Credits######################################################
# Coded by: Humberto Arocha humberto@openerp.com.ve
# Angelica Barrios angelicaisabelb@gmail.com
# Jordi Esteve <jesteve@zikzakmedia.com>
@ -35,6 +35,8 @@ 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):
@ -58,7 +60,6 @@ class account_balance(report_sxw.rml_parse):
})
self.context = context
def get_fiscalyear_text(self, form):
"""
Returns the fiscal year text used on the report.
@ -66,17 +67,20 @@ class account_balance(report_sxw.rml_parse):
fiscalyear_obj = self.pool.get('account.fiscalyear')
fiscalyear = None
if form.get('fiscalyear'):
fiscalyear = fiscalyear_obj.browse(self.cr, self.uid, form['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))
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']
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':
@ -93,7 +97,8 @@ class account_balance(report_sxw.rml_parse):
return day, year and month
'''
if form['filter'] in ['bydate', 'all']:
months=["Enero","Febrero","Marzo","Abril","Mayo","Junio","Julio","Agosto","Septiembre","Octubre","Noviembre","Diciembre"]
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]
@ -114,18 +119,21 @@ class account_balance(report_sxw.rml_parse):
"""
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)])
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)])
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) + ' '
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)
@ -135,11 +143,13 @@ class account_balance(report_sxw.rml_parse):
return False
def exchange_name(self, form):
self.from_currency_id = self.get_company_currency(form['company_id'] and type(form['company_id']) in (list,tuple) and form['company_id'][0] or form['company_id'])
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']
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):
@ -159,7 +169,6 @@ class account_balance(report_sxw.rml_parse):
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 = []
@ -168,7 +177,8 @@ class account_balance(report_sxw.rml_parse):
#~ 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'])
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,
@ -224,7 +234,8 @@ class account_balance(report_sxw.rml_parse):
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)
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:
@ -238,7 +249,7 @@ class account_balance(report_sxw.rml_parse):
#############################################################################
# CONTEXT FOR ENDIND BALANCE #
#############################################################################
#######################################################################
def _ctx_end(ctx):
ctx_end = ctx
@ -253,9 +264,11 @@ class account_balance(report_sxw.rml_parse):
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))])
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)])
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']
@ -266,12 +279,14 @@ class account_balance(report_sxw.rml_parse):
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)])
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()
@ -282,36 +297,45 @@ class account_balance(report_sxw.rml_parse):
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)])
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'])])
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)])
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'])
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']
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']:
if 'account_list' in form 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')
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')
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):
@ -324,13 +348,17 @@ class account_balance(report_sxw.rml_parse):
# 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)
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)
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)
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))
credit_account_ids = list(set(
credit_account_ids) - set(debit_account_ids))
#
# Generate the report lines (checking each account)
@ -339,12 +367,15 @@ class account_balance(report_sxw.rml_parse):
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')
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'))
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')
period_ids = period_obj.search(self.cr, self.uid, [(
'fiscalyear_id', '=', fiscalyear.id), ('special', '=', False)], order='date_start asc')
a = 0
l = []
p = []
@ -361,7 +392,8 @@ class account_balance(report_sxw.rml_parse):
#~ 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')
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
@ -400,7 +432,6 @@ class account_balance(report_sxw.rml_parse):
result_acc = []
tot = {}
for aa_id in account_ids:
id = aa_id[0]
@ -426,20 +457,24 @@ class account_balance(report_sxw.rml_parse):
form['periods'] = p_id
ctx_init = _ctx_init(self.context.copy())
aa_brw_init = account_obj.browse(self.cr, self.uid, id, ctx_init)
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)
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])
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])
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),
@ -452,20 +487,24 @@ class account_balance(report_sxw.rml_parse):
form['periods'] = period_ids
ctx_init = _ctx_init(self.context.copy())
aa_brw_init = account_obj.browse(self.cr, self.uid, id, ctx_init)
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)
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])
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])
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),
@ -479,20 +518,24 @@ class account_balance(report_sxw.rml_parse):
form['periods'] = [p_id]
ctx_init = _ctx_init(self.context.copy())
aa_brw_init = account_obj.browse(self.cr, self.uid, id, ctx_init)
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)
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])
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])
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),
@ -505,20 +548,24 @@ class account_balance(report_sxw.rml_parse):
form['periods'] = period_ids
ctx_init = _ctx_init(self.context.copy())
aa_brw_init = account_obj.browse(self.cr, self.uid, id, ctx_init)
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)
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])
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])
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),
@ -528,10 +575,13 @@ class account_balance(report_sxw.rml_parse):
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)
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])
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),
@ -559,24 +609,30 @@ class account_balance(report_sxw.rml_parse):
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)
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)
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)
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:
@ -607,7 +663,6 @@ class account_balance(report_sxw.rml_parse):
else:
res['mayor'] = []
if to_include:
result_acc.append(res)
#

23
account_financial_report/view/account_view.xml

@ -1,23 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<!--
=====================================================
Vista para agregar ala vista en lista de la lista de
cuentas contables el campo padre.
=====================================================
-->
<record id="view_account_search_padre" model="ir.ui.view">
<field name="name">account.account.search.padre</field>
<field name="model">account.account</field>
<field name="type">search</field>
<field name="inherit_id" ref="account.view_account_search"/>
<field name="arch" type="xml">
<xpath expr="//field[@name='code']" position="after">
<field name="parent_id"/>
</xpath>
</field>
</record>
</data>
</openerp>
Loading…
Cancel
Save