account: account balance report improvement (not yet finished)

bzr revid: qdp-launchpad@tinyerp.com-20100706093231-n3zj7v8nq42aujuy
This commit is contained in:
qdp-launchpad@tinyerp.com 2010-07-06 11:32:31 +02:00
parent a9df8e33ae
commit 470916f5d6
5 changed files with 178 additions and 207 deletions

View File

@ -32,6 +32,7 @@ class account_move_line(osv.osv):
_description = "Entry Lines"
def _query_get(self, cr, uid, obj='l', context={}):
print 'dans le query_get', context
fiscalyear_obj = self.pool.get('account.fiscalyear')
fiscalperiod_obj = self.pool.get('account.period')
fiscalyear_ids = []

View File

@ -32,9 +32,19 @@ from report import report_sxw
import osv
import tools
import pooler
from tools.translate import _
class account_balance(report_sxw.rml_parse):
_name = 'report.account.account.balance'
def set_context(self, objects, data, ids, report_type = None):
new_ids = ids
if (data['model'] == 'ir.ui.menu'):
new_ids = 'chart_account_id' in data['form'] and [data['form']['chart_account_id']] or []
objects = self.pool.get('account.account').browse(self.cr, self.uid, new_ids)
self.query_get_clause = data['form']['query_line'] or ''
super(account_balance, self).set_context(objects, data, new_ids, report_type)
def __init__(self, cr, uid, name, context=None):
super(account_balance, self).__init__(cr, uid, name, context=context)
self.sum_debit = 0.00
@ -86,7 +96,7 @@ class account_balance(report_sxw.rml_parse):
else:
result+=r.name+", "
return str(result and result[:-1]) or 'ALL'
return str(result and result[:-1]) or _('ALL')
def lines(self, form, ids=[], done=None, level=1):
if not ids:
@ -95,36 +105,16 @@ class account_balance(report_sxw.rml_parse):
return []
if not done:
done={}
if form.has_key('Account_list') and form['Account_list']:
ids = [form['Account_list']]
del form['Account_list']
res={}
result_acc=[]
ctx = self.context.copy()
ctx['fiscalyear'] = form['fiscalyear_id']
if form['filter'] == 'filter_period':
periods = form['periods']
if not periods:
sql = """
Select min(p.date_start) as start_date,max(p.date_stop) as stop_date from account_period as p where p.fiscalyear_id = %s
"""
sqlargs = (form['fiscalyear'],)
else:
sql = """
Select min(p.date_start) as start_date,max(p.date_stop) as stop_date from account_period as p where p.id in %s
"""
sqlargs = (tuple(periods),)
self.cr.execute(sql, sqlargs)
res = self.cr.dictfetchall()
ctx['periods'] = form['periods']
elif form['filter'] == 'filter_date':
ctx['date_from'] = form['date_from']
ctx['date_to'] = form['date_to']
elif form['filter'] == 'filter_no' :
ctx['periods'] = form['periods']
ctx['date_from'] = form['date_from']
ctx['date_to'] = form['date_to']
# accounts = self.pool.get('account.account').browse(self.cr, self.uid, ids, ctx)
# def cmp_code(x, y):
# return cmp(x.code, y.code)
@ -133,7 +123,11 @@ class account_balance(report_sxw.rml_parse):
child_ids = self.pool.get('account.account')._get_children_and_consol(self.cr, self.uid, ids, ctx)
if child_ids:
ids = child_ids
print 'on va faire un read'
accounts = self.pool.get('account.account').read(self.cr, self.uid, ids, ['type','code','name','debit','credit','balance','parent_id'], ctx)
print 'on a fait un read'
import pdb
pdb.set_trace()
for account in accounts:
if account['id'] in done:
continue

View File

@ -245,11 +245,11 @@
<td><para style="P10">Balance</para></td>
</tr>
<tr>
<td><para style="P14">[[ repeatIn(lines(data['form']), 'a') ]]<font>[[ a['level']&gt;2 and setTag('para','para',{'fontName':"Helvetica"}) ]]</font><i>[[ a['code'] or removeParentNode('tr') ]]</i></para></td>
<td><para style="P14"><font>[[ a['level']&gt;2 and setTag('para','para',{'fontName':"Helvetica"}) ]]</font><font color="white">[[ '..'*(a['level']-1) ]]</font><font>[[ a['name'] ]]</font></para></td>
<td><para style="P3"><font>[[ a['level']&gt;2 and setTag('para','para',{'fontName':"Helvetica"}) ]]</font><font>[[ a['type']=='view' and removeParentNode('font') ]][[ formatLang(a['debit']) ]]</font><font>[[ a['type']&lt;&gt;'view' and removeParentNode('font') ]] [[formatLang(a['debit']) ]]</font></para></td>
<td><para style="P3"><font>[[ a['level']&gt;2 and setTag('para','para',{'fontName':"Helvetica"}) ]]</font><font>[[ a['type']=='view' and removeParentNode('font') ]][[ formatLang(a['credit']) ]]</font><font>[[ a['type']&lt;&gt;'view' and removeParentNode('font') ]] [[ formatLang(a['credit']) ]]</font></para></td>
<td><para style="P3"><font>[[ a['level']&gt;2 and setTag('para','para',{'fontName':"Helvetica"}) ]]</font><font>[[ a['type']=='view' and removeParentNode('font') ]][[ formatLang(a['balance']) ]]</font><font>[[ a['type']&lt;&gt;'view' and removeParentNode('font') ]] [[ formatLang(a['balance']) ]]</font></para></td>
<td><para style="P14">[[ repeatIn(lines(data['form']), 'a') ]]<!--<font>[[ a['level']&gt;2 and setTag('para','para',{'fontName':"Helvetica"}) ]]</font><i>[[ a['code'] or removeParentNode('tr') ]]</i>--></para></td>
<td><para style="P14"><!--<font>[[ a['level']&gt;2 and setTag('para','para',{'fontName':"Helvetica"}) ]]</font><font color="white">[[ '..'*(a['level']-1) ]]</font><font>[[ a['name'] ]]</font>--></para></td>
<td><para style="P3"><!--<font>[[ a['level']&gt;2 and setTag('para','para',{'fontName':"Helvetica"}) ]]</font><font>[[ a['type']=='view' and removeParentNode('font') ]][[ formatLang(a['debit']) ]]</font><font>[[ a['type']&lt;&gt;'view' and removeParentNode('font') ]] [[formatLang(a['debit']) ]]</font>--></para></td>
<td><para style="P3"><!--<font>[[ a['level']&gt;2 and setTag('para','para',{'fontName':"Helvetica"}) ]]</font><font>[[ a['type']=='view' and removeParentNode('font') ]][[ formatLang(a['credit']) ]]</font><font>[[ a['type']&lt;&gt;'view' and removeParentNode('font') ]] [[ formatLang(a['credit']) ]]</font>--></para></td>
<td><para style="P3"><!--<font>[[ a['level']&gt;2 and setTag('para','para',{'fontName':"Helvetica"}) ]]</font><font>[[ a['type']=='view' and removeParentNode('font') ]][[ formatLang(a['balance']) ]]</font><font>[[ a['type']&lt;&gt;'view' and removeParentNode('font') ]] [[ formatLang(a['balance']) ]]</font>--></para></td>
</tr>
</blockTable>
</story>

View File

@ -30,40 +30,36 @@ class account_balance_report(osv.osv_memory):
_name = 'account.balance.report'
_description = 'Account Balance Report'
_columns = {
'company_id': fields.many2one('res.company', 'Company', required=True),
'display_account': fields.selection([('bal_all','All'), ('bal_mouvement','With movements'),
('bal_solde','With balance is not equal to 0'),
],'Display accounts'),
],'Display accounts', required=True),
}
_defaults = {
'display_account': 'bal_all'
}
def default_get(self, cr, uid, fields, context=None):
""" To get default values for the object.
@param self: The object pointer.
@param cr: A database cursor
@param uid: ID of the user currently logged in
@param fields: List of fields for which we want default values
@param context: A standard dictionary
@return: A dictionary which of fields with values.
"""
res = {}
if 'journal_ids' in fields:# FIX me!!
res['journal_ids'] = []
return res
else:
result = super(account_balance_report, self).default_get(cr, uid, fields, context=context)
result.update({'company_id':self.pool.get('account.account').read(cr, uid, result['chart_account_id'], context=context)['company_id']})
return result
# def default_get(self, cr, uid, fields, context=None):
# """ To get default values for the object.
# @param self: The object pointer.
# @param cr: A database cursor
# @param uid: ID of the user currently logged in
# @param fields: List of fields for which we want default values
# @param context: A standard dictionary
# @return: A dictionary which of fields with values.
# """
# res = {}
# if 'journal_ids' in fields:# FIX me!!
# res['journal_ids'] = []
# return res
# else:
# result = super(account_balance_report, self).default_get(cr, uid, fields, context=context)
# result.update({'company_id':self.pool.get('account.account').read(cr, uid, result['chart_account_id'], context=context)['company_id']})
# return result
def _print_report(self, cr, uid, ids, data, query_line, context=None):
if data['model']=='ir.ui.menu':
data['ids'] = [data['form']['chart_account_id']]
data['form'].update(self.read(cr, uid, ids, ['display_account', 'company_id',])[0])
data['form']['query_get'] = query_line
data['form']['query_line'] = query_line
return { 'type': 'ir.actions.report.xml', 'report_name': 'account.account.balance', 'datas': data, 'nodestroy':True, }
account_balance_report()

View File

@ -2,36 +2,17 @@
<openerp>
<data>
<record id="account_report_balance_view" model="ir.ui.view">
<field name="name">Account Balance</field>
<field name="model">account.balance.report</field>
<field name="type">form</field>
<field name="inherit_id" ref="account_common_report_view" />
<field name="arch" type="xml">
<form string="Print Account Balance" >
<group width="600" height="250">
<group colspan="4" col="4">
<field name="chart_account_id" colspan="2" widget='selection'/>
<field name="fiscalyear_id"/>
<field name="filter"/>
<field name="company_id"/>
<field name="fiscalyear_id" position="after">
<field name="display_account"/>
</group>
<group attrs="{'invisible':[('filter','!=','filter_period')]}">
<separator string="Periods" colspan="4"/>
<field name="period_from"/>
<field name="period_to"/>
</group>
<group colspan="4" attrs="{'invisible':[('filter','!=','filter_date')]}">
<separator string="Date" colspan="4"/>
<field name="date_from"/>
<field name="date_to"/>
</group>
<group colspan="4" col="4" >
<button icon="gtk-cancel" special="cancel" string="Cancel"/>
<button icon="gtk-print" name="check_report" string="Print" type="object"/>
</group>
</group>
</form>
<newline/>
</field>
</field>
</record>
<record id="action_account_balance_menu" model="ir.actions.act_window">
@ -43,7 +24,6 @@
<field name="view_id" ref="account_report_balance_view"/>
<field name="target">new</field>
</record>
<menuitem
icon="STOCK_PRINT"
name="Account Balance"