Browse Source

[AUTOPEP8][account_financial_report]


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

78
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',
@ -89,7 +112,16 @@ class account_financial_report(osv.osv):
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

38
account_financial_report/report/parser.py

@ -62,14 +62,15 @@ 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:])
@ -269,7 +270,8 @@ class account_balance(report_sxw.rml_parse):
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'],
i, d, c, b = det['balanceinit'], det[
'debit'], det['credit'], det['balance'],
if not any([i, d, c, b]): if not any([i, d, c, b]):
continue continue
data = { data = {
@ -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 #
####################################################################### #######################################################################
@ -612,12 +612,15 @@ class account_balance(report_sxw.rml_parse):
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),
('id', 'in',
account_consol_ids),
('type', '=', 'view')])) ('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
@ -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)

6
account_financial_report/wizard/wizard.py

@ -51,9 +51,9 @@ 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),

Loading…
Cancel
Save