[IMP] account: low level accounting reports imp
bzr revid: qdp-launchpad@openerp.com-20110824233151-g7fj950htmhtm06g
This commit is contained in:
@@ -2611,21 +2611,38 @@ class account_low_level_report(osv.osv):
|
||||
_name = "account.low.level.report"
|
||||
_description = "Account Report"
|
||||
|
||||
def _get_balance(self, cr, uid, ids, context=None):
|
||||
balance = 0.0
|
||||
def _get_children_by_order(self, cr, uid, ids, context=None):
|
||||
res = []
|
||||
for id in ids:
|
||||
res.append(id)
|
||||
ids2 = self.search(cr, uid, [('parent_id', '=', id)], order='sequence ASC', context=context)
|
||||
res += self._get_children_by_order(cr, uid, ids2, context=context)
|
||||
return res
|
||||
|
||||
def _get_balance(self, cr, uid, ids, name, args, context=None):
|
||||
res = {}
|
||||
res_all = {}
|
||||
for report in self.browse(cr, uid, ids, context=context):
|
||||
if report.type == 'accounts':
|
||||
balance = 0.0
|
||||
if report.id in res_all:
|
||||
balance = res_all[report.id]
|
||||
elif report.type == 'accounts':
|
||||
# it's the sum of balance of the linked accounts
|
||||
for a in child.account_ids:
|
||||
for a in report.account_ids:
|
||||
balance += a.balance
|
||||
elif report.type == 'account_report' and report.account_report_id:
|
||||
# it's the amount of the linked report
|
||||
balance = report.account_report_id.balance
|
||||
elif report.type == 'sum':
|
||||
# it's the sum of balance of the children of this account.report
|
||||
for child in report.children_ids:
|
||||
balance += child.balance
|
||||
return balance
|
||||
#for child in report.children_ids:
|
||||
res2 = self._get_balance(cr, uid, [rec.id for rec in report.children_ids], 'balance', False, context=context)
|
||||
res_all.update(res2)
|
||||
for key, value in res2.items():
|
||||
balance += value
|
||||
res[report.id] = balance
|
||||
res_all[report.id] = balance
|
||||
return res
|
||||
|
||||
_columns = {
|
||||
'name': fields.char('Report Name', size=128, required=True),
|
||||
|
||||
@@ -94,9 +94,8 @@ class report_account_common(report_sxw.rml_parse, common_report_header):
|
||||
|
||||
def get_lines(self, data):
|
||||
lines = []
|
||||
import pdb;pdb.set_trace()
|
||||
ids2 = self.search(cr, uid, [('parent_id', 'child_of', data['form']['report_id'])], context=self.context)
|
||||
for report in self.pool.get('account.low.level.report').browse(self.cr, self.uid, ids2, context=self.context):
|
||||
ids2 = self.pool.get('account.low.level.report')._get_children_by_order(self.cr, self.uid, [data['form']['account_report_id'][0]], context=data['form']['used_context'])
|
||||
for report in self.pool.get('account.low.level.report').browse(self.cr, self.uid, ids2, context=data['form']['used_context']):
|
||||
vals = {
|
||||
'name': report.name,
|
||||
'balance': report.balance,
|
||||
|
||||
@@ -231,25 +231,19 @@
|
||||
<font color="white"> </font>
|
||||
</para>
|
||||
<para style="terp_header">Accounts</para>
|
||||
<blockTable colWidths="110.0,153.0,100.0,120.0" style="Table_Account_Line_Title">
|
||||
<blockTable colWidths="263.0,100.0" style="Table_Account_Line_Title">
|
||||
<tr>
|
||||
<td>
|
||||
<para style="terp_default_Bold_9">Code</para>
|
||||
</td>
|
||||
<td>
|
||||
<para style="terp_default_Bold_9">Name</para>
|
||||
</td>
|
||||
<td>
|
||||
<para style="terp_tblheader_Details_Right">Balance</para>
|
||||
</td>
|
||||
<td>
|
||||
<para style="terp_tblheader_Details_Right">[[ r['label'] ]]</para>
|
||||
</td>
|
||||
</tr>
|
||||
<tr style="Table3">
|
||||
[[ repeatIn(get_lines(r['id'], data), 'a') ]]
|
||||
<td>[[a.name]]</td>
|
||||
<td>[[a.balance]]</td>
|
||||
[[ repeatIn(get_lines(data), 'a') ]]
|
||||
<td>[[a.get('name', '')]]</td>
|
||||
<td>[[a.get('balance',0.0)]]</td>
|
||||
|
||||
<!--
|
||||
[[ repeatIn(get_account_details(r['id'], data), 'a') ]]
|
||||
|
||||
@@ -28,8 +28,7 @@ class accounting_report(osv.osv_memory):
|
||||
|
||||
_columns = {
|
||||
'enable_filter': fields.boolean('Enable Comparison'),
|
||||
'account_details': fields.boolean('Details by Account', help="Print Report with the account details."),
|
||||
'account_report_id': fields.many2one('account.report', 'Account Reports', required=True),
|
||||
'account_report_id': fields.many2one('account.low.level.report', 'Account Reports', required=True),
|
||||
'label_filter': fields.char('Column Label', size=32, help="This label will be displayed on report to show the balance computed for the given comparison filter."),
|
||||
'fiscalyear_id_cmp': fields.many2one('account.fiscalyear', 'Fiscal Year', help='Keep empty for all open fiscal year'),
|
||||
'filter_cmp': fields.selection([('filter_no', 'No Filters'), ('filter_date', 'Date'), ('filter_period', 'Periods')], "Filter by", required=True),
|
||||
@@ -48,7 +47,7 @@ class accounting_report(osv.osv_memory):
|
||||
data['form'].update(self.read(cr, uid, ids, ['account_report_id', 'enable_filter', 'account_details', 'label_filter'], context=context)[0])
|
||||
return {
|
||||
'type': 'ir.actions.report.xml',
|
||||
'report_name': 'accounting.report',
|
||||
'report_name': 'account.low.level.report',
|
||||
'datas': data,
|
||||
}
|
||||
|
||||
|
||||
@@ -10,7 +10,6 @@
|
||||
<field name="arch" type="xml">
|
||||
<xpath expr="//field[@name='target_move']" position="after">
|
||||
<field name="account_report_id" domain="[('parent_id','=',False)]"/>
|
||||
<field name="account_details"/>
|
||||
<field name="enable_filter"/>
|
||||
</xpath>
|
||||
<xpath expr="//notebook/page[@string='Filters']" position="after">
|
||||
|
||||
Reference in New Issue
Block a user