Browse Source

[IMP] Optimizand parser code.


			
			
				6.0
			
			
		
Miguel Delgado 13 years ago
parent
commit
37097a0c03
  1. 22
      account_financial_report/report/account_balance.py
  2. 25
      account_financial_report/report/account_balance_2_cols.py
  3. 24
      account_financial_report/report/account_balance_4_cols.py
  4. 6
      account_financial_report/report/account_report_report.xml
  5. 20
      account_financial_report/wizard/account_report_wizard.xml
  6. 6
      account_financial_report/wizard/wizard_account_balance_2_report.py
  7. 6
      account_financial_report/wizard/wizard_account_balance_4_report.py
  8. 6
      account_financial_report/wizard/wizard_account_balance_report.py
  9. 6
      account_financial_report/wizard/wizard_report_report.xml

22
account_financial_report/report/account_balance.py

@ -39,7 +39,6 @@ class account_balance(report_sxw.rml_parse):
def __init__(self, cr, uid, name, context):
print 'INICIO: ',datetime.datetime.now()
super(account_balance, self).__init__(cr, uid, name, context)
self.sum_debit = 0.00
self.sum_credit = 0.00
@ -198,10 +197,22 @@ class account_balance(report_sxw.rml_parse):
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 = account_obj.read(self.cr, self.uid, aa_id[0], ['type','code','name','balance','parent_id','level'], ctx)
new_acc.update({'label':aa_id[1],'total':aa_id[2]})
accounts.append(new_acc)
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)
@ -266,7 +277,6 @@ class account_balance(report_sxw.rml_parse):
if form['tot_check'] and res['type'] == 'view' and res['level'] == 1 and (res['id'] not in tot):
tot[res['id']] = True
tot_eje += res['balance']
print 'FIN: ',datetime.datetime.now()
if form['tot_check']:
str_label = form['lab_str']
res2 = {
@ -280,6 +290,6 @@ class account_balance(report_sxw.rml_parse):
return result_acc
report_sxw.report_sxw('report.account.account.balance.gene',
'wizard.report.account.balance.gene',
'addons/l10n_co_account_financial_report/report/balance_full.rml',
'account_financial_report/report/balance_full.rml',
parser=account_balance,
header=False)

25
account_financial_report/report/account_balance_2_cols.py

@ -39,7 +39,6 @@ class account_balance(report_sxw.rml_parse):
def __init__(self, cr, uid, name, context):
print 'INICIO: ',datetime.datetime.now()
super(account_balance, self).__init__(cr, uid, name, context)
self.sum_debit = 0.00
self.sum_credit = 0.00
@ -92,7 +91,7 @@ class account_balance(report_sxw.rml_parse):
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['state'] in ['byperiod', 'all']:
period_ids = form['periods'][0][2]
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
@ -174,10 +173,23 @@ class account_balance(report_sxw.rml_parse):
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 = account_obj.read(self.cr, self.uid, aa_id[0], ['type','code','name','debit','credit','parent_id','level'], ctx)
new_acc.update({'label':aa_id[1],'total':aa_id[2]})
accounts.append(new_acc)
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 \
@ -248,10 +260,9 @@ class account_balance(report_sxw.rml_parse):
'total': True,
}
result_acc.append(res2)
print 'FIN: ',datetime.datetime.now()
return result_acc
report_sxw.report_sxw('report.account.account.balance.gene.2',
'wizard.report.account.balance.gene.2',
'addons/l10n_co_account_financial_report/report/balance_full_2_cols.rml',
'account_financial_report/report/balance_full_2_cols.rml',
parser=account_balance,
header=False)

24
account_financial_report/report/account_balance_4_cols.py

@ -39,7 +39,6 @@ class account_balance(report_sxw.rml_parse):
def __init__(self, cr, uid, name, context):
print 'INICIO: ',datetime.datetime.now()
super(account_balance, self).__init__(cr, uid, name, context)
self.sum_debit = 0.00
self.sum_credit = 0.00
@ -117,10 +116,7 @@ class account_balance(report_sxw.rml_parse):
return []
if not done:
done = {}
print "Lista Form %s"%form
print "Tipo de Obj %s"%type(form)
print "form:%s"%form
if form.has_key('account_list') and form['account_list']:
account_ids = form['account_list']
del form['account_list']
@ -174,26 +170,16 @@ class account_balance(report_sxw.rml_parse):
ctx = self.context.copy()
ctx['state'] = form.get('state','all')
ctx['fiscalyear'] = fiscalyear.id
print "Fiscal year %s"%ctx['fiscalyear']
ctx['periods'] = period_obj.search(self.cr, self.uid, [('fiscalyear_id','=',fiscalyear.id),('special','=',False)])
print "Periodos del Context: %s"%ctx['periods']
if form['state'] in ['byperiod', 'all']:
print "PERIODOS ANTERIORES DEBIT / CREDIT: ",ctx['periods']
ctx['periods'] = period_obj.search(self.cr, self.uid, [('id','in',form['periods'] or ctx['periods']),('special','=',False)])
print "PERIODOS DESPUES DEBIT / CREDIT: ",ctx['periods']
#~ ctx['periods'] = form['periods']
if form['state'] in ['bydate', 'all']:
ctx['date_from'] = form['date_from']
ctx['date_to'] = form['date_to']
accounts=[]
print 'INICIANDO CALCULO DEBIT/CREDIT: ',datetime.datetime.now()
val = account_obj.browse(self.cr, self.uid, [aa_id[0] for aa_id in account_ids], ctx)
print "Valor de Account_ids en get_children: %s"%account_ids
print "Valor de context %s"%ctx
#~ val = account_obj.browse(self.cr, self.uid, account_ids, ctx)
print 'INTERMEDIO CALCULO DEBIT/CREDIT: ',datetime.datetime.now()
c = 0
for aa_id in account_ids:
new_acc = {
@ -209,9 +195,7 @@ class account_balance(report_sxw.rml_parse):
'total' :aa_id[2],
}
c += 1
print "Diccionario new_acc: %s"%new_acc
accounts.append(new_acc)
print 'FINALIZANDO CALCULO DEBIT/CREDIT: ',datetime.datetime.now()
def missing_period():
ctx['fiscalyear'] = fiscalyear_obj.search(self.cr, self.uid, [('date_stop','<',fiscalyear.date_start)],order='date_stop') and \
@ -230,10 +214,8 @@ class account_balance(report_sxw.rml_parse):
if form['state'] in ['byperiod', 'all']:
ctx['periods'] = form['periods']
print "PERIODOS ANTERIORES ctx['periods']: ",ctx['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)])
print "PERIODOS DESPUES ctx['periods']: ",ctx['periods']
if not ctx['periods']:
missing_period()
elif form['state'] in ['bydate']:
@ -249,8 +231,6 @@ class account_balance(report_sxw.rml_parse):
for acc in account_obj.browse(self.cr, self.uid, [x[0] for x in account_ids], ctx):
period_balanceinit[acc['id']] = acc.balance
print 'FINALIZANDO CALCULO INITIAL BALANCE: ',datetime.datetime.now()
#
# Generate the report lines (checking each account)
#
@ -329,11 +309,9 @@ class account_balance(report_sxw.rml_parse):
'total': True,
}
result_acc.append(res2)
print 'FIN: ',datetime.datetime.now()
print "result_acc %s"%result_acc
return result_acc
report_sxw.report_sxw('report.wizard.report.reporte',
'wizard.report',
'l10n_co_account_financial_report/report/balance_full_4_cols.rml',
'account_financial_report/report/balance_full_4_cols.rml',
parser=account_balance,
header=False)

6
account_financial_report/report/account_report_report.xml

@ -6,7 +6,7 @@
string="General account balance"
model="account.account"
name="account.account.balance.gene"
rml="l10n_co_account_financial_report/report/balance_full.rml"
rml="account_financial_report/report/balance_full.rml"
header="False"
auto="False"
menu="False"/>
@ -15,7 +15,7 @@
string="General account balance Four Columns"
model="account.account"
name="account.account.balance.gene.4"
rml="l10n_co_account_financial_report/report/balance_full_4_cols.rml"
rml="account_financial_report/report/balance_full_4_cols.rml"
header="False"
auto="False"
menu="False"/>
@ -24,7 +24,7 @@
string="General account balance Two Columns"
model="account.account"
name="account.account.balance.gene.2"
rml="l10n_co_account_financial_report/report/balance_full_2_cols.rml"
rml="account_financial_report/report/balance_full_2_cols.rml"
header="False"
auto="False"
menu="False"/>

20
account_financial_report/wizard/account_report_wizard.xml

@ -15,9 +15,6 @@
<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="account_list" nolabel="1" colspan="4"/>
-->
<field name="display_account" required="True"/>
<field name="display_account_level" required="True" />
</group>
@ -28,20 +25,6 @@
<field name="state" required="True"/>
<newline/>
<!--
<group colspan="4">
<group colspan="4">
<separator string="Date Filter" colspan="4"/>
<field name="date_from"/>
<field name="date_to"/>
</group>
<group colspan="4">
<separator string="Filter on Periods" colspan="4"/>
<field name="periods" colspan="4" nolabel="1" domain="[('fiscalyear_id','=',fiscalyear)]"/>
</group>
</group>
-->
<group attrs="{'invisible':[('state','=','none')]}" colspan="4">
<group attrs="{'invisible':[('state','=','byperiod')]}" colspan="4">
<separator string="Date Filter" colspan="4"/>
@ -201,8 +184,7 @@
<field name="view_id" ref="wizard_report_view3"/>
<field name="target">new</field>
</record>
<menuitem
id="menu_wizard_report3"
name="Reporte Balance "

6
account_financial_report/wizard/wizard_account_balance_2_report.py

@ -102,15 +102,9 @@ class wizard_account_balance_gene_2(osv.osv_memory):
if context is None:
context = {}
data = {}
print "Context %s"%context
print "Data %s"%data
print "Lista IDS:%s"%ids
data['ids'] = context.get('active_ids', [])
data['model'] = context.get('active_model', 'ir.ui.menu')
data['form'] = self.read(cr, uid, ids[0])
print "Context Mod%s"%context
print "Data Mod%s"%data
print "Lista IDS Mod:%s"%ids
return {'type': 'ir.actions.report.xml', 'report_name': 'account.account.balance.gene.2', 'datas': data}
wizard_account_balance_gene_2()

6
account_financial_report/wizard/wizard_account_balance_4_report.py

@ -75,15 +75,9 @@ class wizard_report(osv.osv_memory):
if context is None:
context = {}
data = {}
print "Context %s"%context
print "Data %s"%data
print "Lista IDS:%s"%ids
data['ids'] = context.get('active_ids', [])
data['model'] = context.get('active_model', 'ir.ui.menu')
data['form'] = self.read(cr, uid, ids[0])
print "Context Mod%s"%context
print "Data Mod%s"%data
print "Lista IDS Mod:%s"%ids
return {'type': 'ir.actions.report.xml', 'report_name': 'wizard.report.reporte', 'datas': data}
wizard_report()

6
account_financial_report/wizard/wizard_account_balance_report.py

@ -103,15 +103,9 @@ class wizard_account_balance_gene(osv.osv_memory):
if context is None:
context = {}
data = {}
print "Context %s"%context
print "Data %s"%data
print "Lista IDS:%s"%ids
data['ids'] = context.get('active_ids', [])
data['model'] = context.get('active_model', 'ir.ui.menu')
data['form'] = self.read(cr, uid, ids[0])
print "Context Mod%s"%context
print "Data Mod%s"%data
print "Lista IDS Mod:%s"%ids
return {'type': 'ir.actions.report.xml', 'report_name': 'account.account.balance.gene', 'datas': data}
wizard_account_balance_gene()

6
account_financial_report/wizard/wizard_report_report.xml

@ -7,7 +7,7 @@
menu="True"
model="wizard.report"
name="wizard.report.reporte"
rml="l10n_co_account_financial_report/report/balance_full_4_cols.rml"
rml="account_financial_report/report/balance_full_4_cols.rml"
string="Balance de Comprobacion Wizard 4 Columnas"
header="False"
/>
@ -17,7 +17,7 @@
menu="True"
model="wizard.report.account.balance.gene.2"
name="account.account.balance.gene.2"
rml="l10n_co_account_financial_report/report/balance_full_2_cols.rml"
rml="account_financial_report/report/balance_full_2_cols.rml"
string="Balance de Comprobacion Wizard 2 Columnas"
header="False"
/>
@ -27,7 +27,7 @@
menu="True"
model="wizard.report.account.balance.gene"
name="account.account.balance.gene"
rml="l10n_co_account_financial_report/report/balance_full.rml"
rml="account_financial_report/report/balance_full.rml"
string="Balance de Comprobacion Wizard"
header="False"
/>

Loading…
Cancel
Save