Browse Source

[AUTOPEP8][account_financial_report]


			
			
				pull/7/merge
			
			
		
Humberto Arocha 11 years ago
parent
commit
8ed3576105
  1. 82
      account_financial_report/model/account_financial_report.py
  2. 144
      account_financial_report/report/parser.py
  3. 8
      account_financial_report/wizard/wizard.py

82
account_financial_report/model/account_financial_report.py

@ -38,29 +38,45 @@ class account_financial_report(osv.osv):
_columns = { _columns = {
'name': fields.char('Name', size=128, required=True), 'name': fields.char('Name', size=128, required=True),
'company_id': fields.many2one('res.company', 'Company', 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"),
'journal_ledger': fields.boolean('journal Ledger', help="Allows to Generate an journal Ledger for accounts with moves. Available when Balance Sheet and 'Initial | Debit | Credit | YTD' are selected"),
'partner_balance': fields.boolean('Partner Balance', help="""Allows to
Generate a Partner Balance 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),
'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"),
'journal_ledger': fields.boolean(
'journal Ledger', help="Allows to Generate an journal Ledger for accounts with moves. Available when Balance Sheet and 'Initial | Debit | Credit | YTD' are selected"),
'partner_balance': fields.boolean('Partner Balance', help="Allows to "
"Generate a Partner Balance 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),
'target_move': fields.selection([('posted', 'All Posted Entries'), 'target_move': fields.selection([('posted', 'All Posted Entries'),
('all', 'All Entries'), ('all', 'All Entries'),
], 'Entries to Include', required=True, ], 'Entries to Include', required=True,
help='Print All Accounting Entries or just Posted Accounting Entries'),
help='Print All Accounting Entries or just Posted Accounting Entries'),
#~ Deprecated fields #~ Deprecated fields
'filter': fields.selection([('bydate', 'By Date'), ('byperiod', 'By Period'), ('all', 'By Date and Period'), ('none', 'No Filter')], 'Date/Period Filter'),
'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_to': fields.date('End date'),
'date_from': fields.date('Start date'), 'date_from': fields.date('Start date'),
} }
@ -68,8 +84,15 @@ class account_financial_report(osv.osv):
_defaults = { _defaults = {
'display_account_level': lambda *a: 0, 'display_account_level': lambda *a: 0,
'inf_type': lambda *a: 'BS', '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),
'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', 'display_account': lambda *a: 'bal_mov',
'columns': lambda *a: 'five', 'columns': lambda *a: 'five',
@ -87,9 +110,18 @@ class account_financial_report(osv.osv):
lst = self.search(cr, uid, [( lst = self.search(cr, uid, [(
'name', 'like', new_name)], context=context) 'name', 'like', new_name)], context=context)
if lst: if lst:
new_name = '%s (%s)' % (new_name, len(lst)+1)
new_name = '%s (%s)' % (new_name, len(lst) + 1)
defaults['name'] = new_name defaults['name'] = new_name
return super(account_financial_report, self).copy(cr, uid, id, defaults, context=context)
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): def onchange_inf_type(self, cr, uid, ids, inf_type, context=None):
if context is None: if context is None:
@ -101,7 +133,8 @@ class account_financial_report(osv.osv):
return res return res
def onchange_columns(self, cr, uid, ids, columns, fiscalyear_id, period_ids, context=None):
def onchange_columns(self, cr, uid, ids, columns,
fiscalyear_id, period_ids, context=None):
if context is None: if context is None:
context = {} context = {}
res = {'value': {}} res = {'value': {}}
@ -118,7 +151,8 @@ class account_financial_report(osv.osv):
res['value'].update({'period_ids': []}) res['value'].update({'period_ids': []})
return res return res
def onchange_analytic_ledger(self, cr, uid, ids, company_id, analytic_ledger, context=None):
def onchange_analytic_ledger(
self, cr, uid, ids, company_id, analytic_ledger, context=None):
if context is None: if context is None:
context = {} context = {}
context['company_id'] = company_id context['company_id'] = company_id

144
account_financial_report/report/parser.py

@ -62,19 +62,20 @@ class account_balance(report_sxw.rml_parse):
}) })
self.context = context self.context = context
def get_vat_by_country(self, form): def get_vat_by_country(self, form):
""" """
Return the vat of the partner by country Return the vat of the partner by country
""" """
rc_obj = self.pool.get('res.company') rc_obj = self.pool.get('res.company')
country_code=rc_obj.browse(self.cr, self.uid, form['company_id'][0]).partner_id.country_id.code or ''
string_vat= rc_obj.browse(self.cr, self.uid, form['company_id'][0]).partner_id.vat or ''
country_code = rc_obj.browse(self.cr, self.uid,
form['company_id'][0]).partner_id.country_id.code or ''
string_vat = rc_obj.browse(self.cr, self.uid,
form['company_id'][0]).partner_id.vat or ''
if string_vat: if string_vat:
if country_code=='MX':
if country_code == 'MX':
return '%s' % (string_vat[2:]) return '%s' % (string_vat[2:])
elif country_code=='VE':
return '- %s-%s-%s'%(string_vat[2:3],string_vat[3:11],string_vat[11:12])
elif country_code == 'VE':
return '- %s-%s-%s' % (string_vat[2:3], string_vat[3:11], string_vat[11:12])
else: else:
return string_vat return string_vat
else: else:
@ -119,10 +120,10 @@ class account_balance(report_sxw.rml_parse):
if form['filter'] in ['bydate', 'all']: if form['filter'] in ['bydate', 'all']:
months = ["Enero", "Febrero", "Marzo", "Abril", "Mayo", "Junio", months = ["Enero", "Febrero", "Marzo", "Abril", "Mayo", "Junio",
"Julio", "Agosto", "Septiembre", "Octubre", "Noviembre", "Diciembre"] "Julio", "Agosto", "Septiembre", "Octubre", "Noviembre", "Diciembre"]
mes = months[time.strptime(form['date_to'], "%Y-%m-%d")[1]-1]
mes = months[time.strptime(form['date_to'], "%Y-%m-%d")[1] - 1]
ano = time.strptime(form['date_to'], "%Y-%m-%d")[0] ano = time.strptime(form['date_to'], "%Y-%m-%d")[0]
dia = time.strptime(form['date_to'], "%Y-%m-%d")[2] 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)
return _('From ') + self.formatLang(form['date_from'], date=True) + _(' to ') + self.formatLang(form['date_to'], date=True)
elif form['filter'] in ['byperiod', 'all']: elif form['filter'] in ['byperiod', 'all']:
aux = [] aux = []
period_obj = self.pool.get('account.period') period_obj = self.pool.get('account.period')
@ -131,7 +132,7 @@ class account_balance(report_sxw.rml_parse):
aux.append(period.date_start) aux.append(period.date_start)
aux.append(period.date_stop) aux.append(period.date_stop)
sorted(aux) sorted(aux)
return _('From ')+self.formatLang(aux[0], date=True)+_(' to ')+self.formatLang(aux[-1], date=True)
return _('From ') + self.formatLang(aux[0], date=True) + _(' to ') + self.formatLang(aux[-1], date=True)
def get_periods_and_date_text(self, form): def get_periods_and_date_text(self, form):
""" """
@ -218,7 +219,7 @@ class account_balance(report_sxw.rml_parse):
""" """
WHERE_POSTED = '' WHERE_POSTED = ''
if ctx.get('state','posted')=='posted':
if ctx.get('state', 'posted') == 'posted':
WHERE_POSTED = "AND am.state = 'posted'" WHERE_POSTED = "AND am.state = 'posted'"
cur_periods = ', '.join([str(i) for i in ctx['periods']]) cur_periods = ', '.join([str(i) for i in ctx['periods']])
@ -229,11 +230,11 @@ class account_balance(report_sxw.rml_parse):
AND aa.id = %s AND aa.id = %s
AND aml.state <> 'draft' AND aml.state <> 'draft'
""" % (init_periods, account['id']) """ % (init_periods, account['id'])
query_init = sql_query%('SUM(aml.debit) AS init_dr',
'SUM(aml.credit) AS init_cr',
'0.0 AS bal_dr',
'0.0 AS bal_cr',
WHERE+WHERE_POSTED)
query_init = sql_query % ('SUM(aml.debit) AS init_dr',
'SUM(aml.credit) AS init_cr',
'0.0 AS bal_dr',
'0.0 AS bal_cr',
WHERE + WHERE_POSTED)
WHERE = """ WHERE = """
WHERE aml.period_id IN (%s) WHERE aml.period_id IN (%s)
@ -241,11 +242,11 @@ class account_balance(report_sxw.rml_parse):
AND aml.state <> 'draft' AND aml.state <> 'draft'
""" % (cur_periods, account['id']) """ % (cur_periods, account['id'])
query_bal = sql_query%('0.0 AS init_dr',
'0.0 AS init_cr',
'SUM(aml.debit) AS bal_dr',
'SUM(aml.credit) AS bal_cr',
WHERE+WHERE_POSTED)
query_bal = sql_query % ('0.0 AS init_dr',
'0.0 AS init_cr',
'SUM(aml.debit) AS bal_dr',
'SUM(aml.credit) AS bal_cr',
WHERE + WHERE_POSTED)
query = ''' query = '''
SELECT SELECT
@ -263,14 +264,15 @@ class account_balance(report_sxw.rml_parse):
) v ) v
GROUP BY p_idx, partner_name GROUP BY p_idx, partner_name
ORDER BY partner_name ORDER BY partner_name
'''%(query_init,query_bal)
''' % (query_init, query_bal)
self.cr.execute(query) self.cr.execute(query)
res_dict = self.cr.dictfetchall() res_dict = self.cr.dictfetchall()
unknown = False unknown = False
for det in res_dict: for det in res_dict:
i,d,c,b = det['balanceinit'], det['debit'], det['credit'], det['balance'],
if not any([i,d,c,b]):
i, d, c, b = det['balanceinit'], det[
'debit'], det['credit'], det['balance'],
if not any([i, d, c, b]):
continue continue
data = { data = {
'partner_name': det['partner_name'], 'partner_name': det['partner_name'],
@ -296,7 +298,7 @@ class account_balance(report_sxw.rml_parse):
#~ periods = str(tuple(ctx['periods'])) #~ periods = str(tuple(ctx['periods']))
where = """where aml.period_id in (%s) and aa.id = %s and aml.state <> 'draft'""" % ( where = """where aml.period_id in (%s) and aa.id = %s and aml.state <> 'draft'""" % (
periods, account['id']) periods, account['id'])
if ctx.get('state','posted')=='posted':
if ctx.get('state', 'posted') == 'posted':
where += "AND am.state = 'posted'" where += "AND am.state = 'posted'"
sql_detalle = """select aml.id as id, aj.name as diario, aa.name as descripcion, 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, (select name from res_partner where aml.partner_id = id) as partner,
@ -346,7 +348,7 @@ class account_balance(report_sxw.rml_parse):
#~ periods = str(tuple(ctx['periods'])) #~ periods = str(tuple(ctx['periods']))
where = """where aml.period_id in (%s) and aa.id = %s and aml.state <> 'draft'""" % ( where = """where aml.period_id in (%s) and aa.id = %s and aml.state <> 'draft'""" % (
periods, account['id']) periods, account['id'])
if ctx.get('state','posted')=='posted':
if ctx.get('state', 'posted') == 'posted':
where += "AND am.state = 'posted'" where += "AND am.state = 'posted'"
sql_detalle = """SELECT sql_detalle = """SELECT
DISTINCT am.id as am_id, DISTINCT am.id as am_id,
@ -370,9 +372,9 @@ class account_balance(report_sxw.rml_parse):
'name': det['name'], 'name': det['name'],
'date': det['date'], 'date': det['date'],
'period': det['periodo'], 'period': det['periodo'],
'obj': am_obj.browse(self.cr,self.uid,det['am_id'])
'obj': am_obj.browse(self.cr, self.uid, det['am_id'])
}) })
print 'ACCOUNT NAME', am_obj.browse(self.cr,self.uid,det['am_id']).name
print 'ACCOUNT NAME', am_obj.browse(self.cr, self.uid, det['am_id']).name
return res return res
def lines(self, form, level=0): def lines(self, form, level=0):
@ -405,11 +407,9 @@ class account_balance(report_sxw.rml_parse):
ids2.append([aa_brw.id, True, True, aa_brw]) ids2.append([aa_brw.id, True, True, aa_brw])
return ids2 return ids2
#############################################################################
#######################################################################
# CONTEXT FOR ENDIND BALANCE # # CONTEXT FOR ENDIND BALANCE #
####################################################################### #######################################################################
def _ctx_end(ctx): def _ctx_end(ctx):
ctx_end = ctx ctx_end = ctx
ctx_end['filter'] = form.get('filter', 'all') ctx_end['filter'] = form.get('filter', 'all')
@ -443,7 +443,7 @@ class account_balance(report_sxw.rml_parse):
ctx_init['periods'] = period_obj.search(self.cr, self.uid, [( ctx_init['periods'] = period_obj.search(self.cr, self.uid, [(
'fiscalyear_id', '=', ctx_init['fiscalyear']), ('date_stop', '<', fiscalyear.date_start)]) 'fiscalyear_id', '=', ctx_init['fiscalyear']), ('date_stop', '<', fiscalyear.date_start)])
return ctx_init return ctx_init
#############################################################################
#######################################################################
# CONTEXT FOR INITIAL BALANCE # # CONTEXT FOR INITIAL BALANCE #
####################################################################### #######################################################################
@ -490,7 +490,7 @@ class account_balance(report_sxw.rml_parse):
if 'account_list' in form and form['account_list']: if 'account_list' in form and form['account_list']:
account_ids = form['account_list'] account_ids = form['account_list']
account_list= form['account_list']
account_list = form['account_list']
del form['account_list'] del form['account_list']
credit_account_ids = self.get_company_accounts(form['company_id'] and type(form[ credit_account_ids = self.get_company_accounts(form['company_id'] and type(form[
@ -593,31 +593,34 @@ class account_balance(report_sxw.rml_parse):
account_black_ids = account_obj.search(self.cr, self.uid, ( account_black_ids = account_obj.search(self.cr, self.uid, (
[('id', 'in', [i[0] for i in all_account_ids]), [('id', 'in', [i[0] for i in all_account_ids]),
('type', 'not in', ('type', 'not in',
('view', 'consolidation'))]))
('view', 'consolidation'))]))
account_not_black_ids = account_obj.search(self.cr, self.uid, ([('id', 'in', [ account_not_black_ids = account_obj.search(self.cr, self.uid, ([('id', 'in', [
i[0] for i in all_account_ids]),('type', '=', 'view')]))
i[0] for i in all_account_ids]), ('type', '=', 'view')]))
acc_cons_ids = account_obj.search(self.cr, self.uid, ([('id', 'in', [ acc_cons_ids = account_obj.search(self.cr, self.uid, ([('id', 'in', [
i[0] for i in all_account_ids]), ('type', 'in', ('consolidation',))]))
i[0] for i in all_account_ids]), ('type', 'in', ('consolidation',))]))
account_consol_ids = acc_cons_ids and account_obj._get_children_and_consol( account_consol_ids = acc_cons_ids and account_obj._get_children_and_consol(
self.cr, self.uid, acc_cons_ids) or []
self.cr, self.uid, acc_cons_ids) or []
account_black_ids += account_obj.search(self.cr, self.uid, ( account_black_ids += account_obj.search(self.cr, self.uid, (
[('id', 'in', account_consol_ids ),
('type', 'not in',
('view', 'consolidation'))]))
[('id', 'in', account_consol_ids),
('type', 'not in',
('view', 'consolidation'))]))
account_black_ids = list(set(account_black_ids)) account_black_ids = list(set(account_black_ids))
c_account_not_black_ids = account_obj.search(self.cr, self.uid, ([ c_account_not_black_ids = account_obj.search(self.cr, self.uid, ([
('id', 'in', account_consol_ids),
('type', '=', 'view')]))
('id', 'in',
account_consol_ids),
('type', '=', 'view')]))
delete_cons = False delete_cons = False
if c_account_not_black_ids: if c_account_not_black_ids:
delete_cons = set(account_not_black_ids) & set(c_account_not_black_ids) and True or False
account_not_black_ids = list(set(account_not_black_ids) - set(c_account_not_black_ids))
delete_cons = set(account_not_black_ids) & set(
c_account_not_black_ids) and True or False
account_not_black_ids = list(
set(account_not_black_ids) - set(c_account_not_black_ids))
# This could be done quickly with a sql sentence # This could be done quickly with a sql sentence
account_not_black = account_obj.browse( account_not_black = account_obj.browse(
@ -633,7 +636,8 @@ class account_balance(report_sxw.rml_parse):
c_account_not_black_ids = [i.id for i in c_account_not_black] c_account_not_black_ids = [i.id for i in c_account_not_black]
if delete_cons: if delete_cons:
account_not_black_ids = c_account_not_black_ids + account_not_black_ids
account_not_black_ids = c_account_not_black_ids + \
account_not_black_ids
account_not_black = c_account_not_black + account_not_black account_not_black = c_account_not_black + account_not_black
else: else:
acc_cons_brw = account_obj.browse( acc_cons_brw = account_obj.browse(
@ -642,8 +646,10 @@ class account_balance(report_sxw.rml_parse):
acc_cons_brw.reverse() acc_cons_brw.reverse()
acc_cons_ids = [i.id for i in acc_cons_brw] acc_cons_ids = [i.id for i in acc_cons_brw]
account_not_black_ids = c_account_not_black_ids + acc_cons_ids + account_not_black_ids
account_not_black = c_account_not_black + acc_cons_brw + account_not_black
account_not_black_ids = c_account_not_black_ids + \
acc_cons_ids + account_not_black_ids
account_not_black = c_account_not_black + \
acc_cons_brw + account_not_black
all_account_period = {} # All accounts per period all_account_period = {} # All accounts per period
@ -657,7 +663,7 @@ class account_balance(report_sxw.rml_parse):
for p_act in range(limit): for p_act in range(limit):
if limit != 1: if limit != 1:
if p_act == limit-1:
if p_act == limit - 1:
form['periods'] = period_ids form['periods'] = period_ids
else: else:
if form['columns'] == 'thirteen': if form['columns'] == 'thirteen':
@ -687,7 +693,7 @@ class account_balance(report_sxw.rml_parse):
'obj': i, 'obj': i,
'debit': d, 'debit': d,
'credit': c, 'credit': c,
'balance': d-c
'balance': d - c
} }
if form['inf_type'] == 'BS': if form['inf_type'] == 'BS':
dict_black.get(i.id)['balanceinit'] = 0.0 dict_black.get(i.id)['balanceinit'] = 0.0
@ -707,12 +713,12 @@ class account_balance(report_sxw.rml_parse):
dict_not_black.get(i.id)['balanceinit'] = 0.0 dict_not_black.get(i.id)['balanceinit'] = 0.0
all_account = dict_black.copy( all_account = dict_black.copy(
) #It makes a copy because they modify
) # It makes a copy because they modify
for acc_id in account_not_black_ids: for acc_id in account_not_black_ids:
acc_childs = dict_not_black.get(acc_id).get('obj').type=='view' \
and dict_not_black.get(acc_id).get('obj').child_id \
or dict_not_black.get(acc_id).get('obj').child_consol_ids
acc_childs = dict_not_black.get(acc_id).get('obj').type == 'view' \
and dict_not_black.get(acc_id).get('obj').child_id \
or dict_not_black.get(acc_id).get('obj').child_consol_ids
for child_id in acc_childs: for child_id in acc_childs:
if child_id.type == 'consolidation' and delete_cons: if child_id.type == 'consolidation' and delete_cons:
continue continue
@ -727,7 +733,7 @@ class account_balance(report_sxw.rml_parse):
child_id.id).get('balanceinit') child_id.id).get('balanceinit')
all_account[acc_id] = dict_not_black[acc_id] all_account[acc_id] = dict_not_black[acc_id]
if p_act == limit-1:
if p_act == limit - 1:
all_account_period['all'] = all_account all_account_period['all'] = all_account
else: else:
if form['columns'] == 'thirteen': if form['columns'] == 'thirteen':
@ -765,7 +771,7 @@ class account_balance(report_sxw.rml_parse):
if form['inf_type'] == 'IS': if form['inf_type'] == 'IS':
d, c, b = map(z, [ d, c, b = map(z, [
all_account_period.get(pn-1).get(id).get('debit', 0.0), all_account_period.get(pn-1).get(id).get('credit', 0.0), all_account_period.get(pn-1).get(id).get('balance', 0.0)])
all_account_period.get(pn - 1).get(id).get('debit', 0.0), all_account_period.get(pn - 1).get(id).get('credit', 0.0), all_account_period.get(pn - 1).get(id).get('balance', 0.0)])
res.update({ res.update({
'dbr%s' % pn: self.exchange(d), 'dbr%s' % pn: self.exchange(d),
'cdr%s' % pn: self.exchange(c), 'cdr%s' % pn: self.exchange(c),
@ -773,8 +779,8 @@ class account_balance(report_sxw.rml_parse):
}) })
else: else:
i, d, c = map(z, [ i, d, c = map(z, [
all_account_period.get(pn-1).get(id).get('balanceinit', 0.0), all_account_period.get(pn-1).get(id).get('debit', 0.0), all_account_period.get(pn-1).get(id).get('credit', 0.0)])
b = z(i+d-c)
all_account_period.get(pn - 1).get(id).get('balanceinit', 0.0), all_account_period.get(pn - 1).get(id).get('debit', 0.0), all_account_period.get(pn - 1).get(id).get('credit', 0.0)])
b = z(i + d - c)
res.update({ res.update({
'dbr%s' % pn: self.exchange(d), 'dbr%s' % pn: self.exchange(d),
'cdr%s' % pn: self.exchange(c), 'cdr%s' % pn: self.exchange(c),
@ -783,7 +789,7 @@ class account_balance(report_sxw.rml_parse):
if form['inf_type'] == 'IS': if form['inf_type'] == 'IS':
d, c, b = map(z, [ d, c, b = map(z, [
all_account_period.get('all').get(id).get('debit', 0.0), all_account_period.get('all').get(id).get('credit',0.0), all_account_period.get('all').get(id).get('balance')])
all_account_period.get('all').get(id).get('debit', 0.0), all_account_period.get('all').get(id).get('credit', 0.0), all_account_period.get('all').get(id).get('balance')])
res.update({ res.update({
'dbr5': self.exchange(d), 'dbr5': self.exchange(d),
'cdr5': self.exchange(c), 'cdr5': self.exchange(c),
@ -791,8 +797,8 @@ class account_balance(report_sxw.rml_parse):
}) })
else: else:
i, d, c = map(z, [ i, d, c = map(z, [
all_account_period.get('all').get(id).get('balanceinit', 0.0), all_account_period.get('all').get(id).get('debit', 0.0), all_account_period.get('all').get(id).get('credit',0.0)])
b = z(i+d-c)
all_account_period.get('all').get(id).get('balanceinit', 0.0), all_account_period.get('all').get(id).get('debit', 0.0), all_account_period.get('all').get(id).get('credit', 0.0)])
b = z(i + d - c)
res.update({ res.update({
'dbr5': self.exchange(d), 'dbr5': self.exchange(d),
'cdr5': self.exchange(c), 'cdr5': self.exchange(c),
@ -814,7 +820,7 @@ class account_balance(report_sxw.rml_parse):
else: else:
i, d, c = map(z, [ i, d, c = map(z, [
all_account_period.get(p_num).get(id).get('balanceinit', 0.0), all_account_period.get(p_num).get(id).get('debit', 0.0), all_account_period.get(p_num).get(id).get('credit', 0.0)]) all_account_period.get(p_num).get(id).get('balanceinit', 0.0), all_account_period.get(p_num).get(id).get('debit', 0.0), all_account_period.get(p_num).get(id).get('credit', 0.0)])
b = z(i+d-c)
b = z(i + d - c)
res.update({ res.update({
'dbr%s' % pn: self.exchange(d), 'dbr%s' % pn: self.exchange(d),
'cdr%s' % pn: self.exchange(c), 'cdr%s' % pn: self.exchange(c),
@ -834,7 +840,7 @@ class account_balance(report_sxw.rml_parse):
else: else:
i, d, c = map(z, [ i, d, c = map(z, [
all_account_period.get('all').get(id).get('balanceinit', 0.0), all_account_period.get('all').get(id).get('debit', 0.0), all_account_period.get('all').get(id).get('credit', 0.0)]) all_account_period.get('all').get(id).get('balanceinit', 0.0), all_account_period.get('all').get(id).get('debit', 0.0), all_account_period.get('all').get(id).get('credit', 0.0)])
b = z(i+d-c)
b = z(i + d - c)
res.update({ res.update({
'dbr13': self.exchange(d), 'dbr13': self.exchange(d),
'cdr13': self.exchange(c), 'cdr13': self.exchange(c),
@ -844,17 +850,17 @@ class account_balance(report_sxw.rml_parse):
else: else:
i, d, c = map(z, [ i, d, c = map(z, [
all_account_period.get('all').get(id).get('balanceinit', 0.0), all_account_period.get('all').get(id).get('debit', 0.0), all_account_period.get('all').get(id).get('credit', 0.0)]) all_account_period.get('all').get(id).get('balanceinit', 0.0), all_account_period.get('all').get(id).get('debit', 0.0), all_account_period.get('all').get(id).get('credit', 0.0)])
b = z(i+d-c)
b = z(i + d - c)
res.update({ res.update({
'balanceinit': self.exchange(i), 'balanceinit': self.exchange(i),
'debit': self.exchange(d), 'debit': self.exchange(d),
'credit': self.exchange(c), 'credit': self.exchange(c),
'ytd': self.exchange(d-c),
'ytd': self.exchange(d - c),
}) })
if form['inf_type'] == 'IS' and form['columns'] == 'one': if form['inf_type'] == 'IS' and form['columns'] == 'one':
res.update({ res.update({
'balance': self.exchange(d-c),
'balance': self.exchange(d - c),
}) })
else: else:
res.update({ res.update({
@ -870,7 +876,7 @@ class account_balance(report_sxw.rml_parse):
to_test = [False] to_test = [False]
if form['display_account'] == 'mov' and aa_id[3].parent_id: if form['display_account'] == 'mov' and aa_id[3].parent_id:
# Include accounts with movements # Include accounts with movements
for x in range(pn-1):
for x in range(pn - 1):
to_test.append(res.get( to_test.append(res.get(
'dbr%s' % x, 0.0) >= 0.005 and True or False) 'dbr%s' % x, 0.0) >= 0.005 and True or False)
to_test.append(res.get( to_test.append(res.get(
@ -880,7 +886,7 @@ class account_balance(report_sxw.rml_parse):
elif form['display_account'] == 'bal' and aa_id[3].parent_id: elif form['display_account'] == 'bal' and aa_id[3].parent_id:
# Include accounts with balance # Include accounts with balance
for x in range(pn-1):
for x in range(pn - 1):
to_test.append(res.get( to_test.append(res.get(
'bal%s' % x, 0.0) >= 0.005 and True or False) 'bal%s' % x, 0.0) >= 0.005 and True or False)
if any(to_test): if any(to_test):
@ -888,7 +894,7 @@ class account_balance(report_sxw.rml_parse):
elif form['display_account'] == 'bal_mov' and aa_id[3].parent_id: elif form['display_account'] == 'bal_mov' and aa_id[3].parent_id:
# Include accounts with balance or movements # Include accounts with balance or movements
for x in range(pn-1):
for x in range(pn - 1):
to_test.append(res.get( to_test.append(res.get(
'bal%s' % x, 0.0) >= 0.005 and True or False) 'bal%s' % x, 0.0) >= 0.005 and True or False)
to_test.append(res.get( to_test.append(res.get(
@ -925,7 +931,8 @@ class account_balance(report_sxw.rml_parse):
elif to_include and form['journal_ledger'] and form['columns'] == 'four' and form['inf_type'] == 'BS' and res['type'] in ('other', 'liquidity', 'receivable', 'payable'): elif to_include and form['journal_ledger'] and form['columns'] == 'four' and form['inf_type'] == 'BS' and res['type'] in ('other', 'liquidity', 'receivable', 'payable'):
res['journal'] = self._get_journal_ledger(res, ctx=ctx_end) res['journal'] = self._get_journal_ledger(res, ctx=ctx_end)
elif to_include and form['partner_balance'] and form['columns'] == 'four' and form['inf_type'] == 'BS' and res['type'] in ('other', 'liquidity', 'receivable', 'payable'): elif to_include and form['partner_balance'] and form['columns'] == 'four' and form['inf_type'] == 'BS' and res['type'] in ('other', 'liquidity', 'receivable', 'payable'):
res['partner'] = self._get_partner_balance(res, ctx_i['periods'], ctx=ctx_end)
res['partner'] = self._get_partner_balance(
res, ctx_i['periods'], ctx=ctx_end)
else: else:
res['mayor'] = [] res['mayor'] = []
@ -1065,4 +1072,3 @@ report_sxw.report_sxw('report.afr.13cols',
'account_financial_report/report/balance_full_13_cols.rml', 'account_financial_report/report/balance_full_13_cols.rml',
parser=account_balance, parser=account_balance,
header=False) header=False)

8
account_financial_report/wizard/wizard.py

@ -51,16 +51,16 @@ class wizard_report(osv.osv_memory):
'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"), '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"),
'journal_ledger': fields.boolean('Journal Ledger', help="Allows to Generate an Journal Ledger for accounts with moves. Available when Balance Sheet and 'Initial | Debit | Credit | YTD' are selected"), 'journal_ledger': fields.boolean('Journal Ledger', help="Allows to Generate an Journal Ledger for accounts with moves. Available when Balance Sheet and 'Initial | Debit | Credit | YTD' are selected"),
'partner_balance': fields.boolean('Partner Balance', help="""Allows to
Generate a Partner Balance for accounts with moves. Available when
Balance Sheet and 'Initial | Debit | Credit | YTD' are selected"""),
'partner_balance': fields.boolean('Partner Balance', help="Allows to "
"Generate a Partner Balance 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'), '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), 'lab_str': fields.char('Description', help='Description for the Summary', size=128),
'target_move': fields.selection([('posted', 'All Posted Entries'), 'target_move': fields.selection([('posted', 'All Posted Entries'),
('all', 'All Entries'), ('all', 'All Entries'),
], 'Entries to Include', required=True, ], 'Entries to Include', required=True,
help='Print All Accounting Entries or just Posted Accounting Entries'),
help='Print All Accounting Entries or just Posted Accounting Entries'),
#~ Deprecated fields #~ Deprecated fields
'filter': fields.selection([('bydate', 'By Date'), ('byperiod', 'By Period'), ('all', 'By Date and Period'), ('none', 'No Filter')], 'Date/Period Filter'), '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_to': fields.date('End date'),

Loading…
Cancel
Save