[IMP] account: account_report improvements. BTW, now it's called 'low level report'

bzr revid: qdp-launchpad@openerp.com-20110824124908-nz0j00v7s6qka0o1
This commit is contained in:
Quentin (OpenERP) 2011-08-24 14:49:08 +02:00
parent ad1db4ffd8
commit cfab7f39f0
9 changed files with 104 additions and 47 deletions

View File

@ -98,7 +98,7 @@ module named account_voucher.
'wizard/account_reconcile_view.xml',
'wizard/account_reconcile_partner_process_view.xml',
'wizard/account_automatic_reconcile_view.xml',
'wizard/account_report_view.xml',
'wizard/account_low_level_report_view.xml',
'project/wizard/project_account_analytic_line_view.xml',
'account_end_fy.xml',
'account_invoice_view.xml',

View File

@ -2607,30 +2607,48 @@ class account_fiscal_position_account_template(osv.osv):
account_fiscal_position_account_template()
class account_report(osv.osv):
_name = "account.report"
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
for report in self.browse(cr, uid, ids, context=context):
if report.type == 'accounts':
# it's the sum of balance of the linked accounts
for a in child.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
_columns = {
'name': fields.char('Name', size=32, required=True),
'parent_id': fields.many2one('account.report', 'Parent'),
'name': fields.char('Report Name', size=128, required=True),
'parent_id': fields.many2one('account.low.level.report', 'Parent'),
'children_ids': fields.one2many('account.low.level.report', 'parent_id', 'Account Report'),
'sequence': fields.integer('Sequence'),
'type': fields.selection([
('sum','Sum'),
('accounts','Accounts'),
('account_report','Account Report'),
],'Report Type'),
'account_ids': fields.many2many('account.account', 'account_account_report', 'report_line_id', 'account_id', 'Accounts'),
],'Type'),
'account_ids': fields.many2many('account.account', 'account_account_low_level_report', 'report_line_id', 'account_id', 'Accounts'),
'note': fields.text('Notes'),
'account_report_id': fields.many2one('account.report', 'Account Report'),
'child_ids': fields.one2many('account.report','parent_id','Children'),
'account_report_id': fields.many2one('account.low.level.report', 'Account Report'),
'balance': fields.function(_get_balance, 'Balance'),
'display_detail': fields.boolean('Display the account list'),
}
_defaults = {
'type': 'sum',
}
account_report()
account_low_level_report()
# Multi charts of Accounts wizard

View File

@ -2707,9 +2707,9 @@ action = self.pool.get('res.config').next(cr, uid, [], context)
Account Reports
-->
<record id="view_account_report_form" model="ir.ui.view">
<field name="name">account.report.form</field>
<field name="model">account.report</field>
<record id="view_account_low_level_report_form" model="ir.ui.view">
<field name="name">account.low.level.report.form</field>
<field name="model">account.low.level.report</field>
<field name="type">form</field>
<field name="arch" type="xml">
<form string="Account Report">
@ -2717,18 +2717,19 @@ action = self.pool.get('res.config').next(cr, uid, [], context)
<field name="parent_id"/>
<field name="sequence"/>
<field name="type"/>
<field name="account_report_id"/>
<field name="account_report_id" attrs="{'readonly': [('type', '!=', 'account_report')]}"/>
<separator string="Accounts" colspan="4"/>
<field name="account_ids" nolabel="1" colspan="4"/>
<field name="display_detail" attrs="{'readonly': [('type', '!=', 'accounts')]}"/>
<field name="account_ids" nolabel="1" colspan="4" attrs="{'readonly': [('type', '!=', 'accounts')]}"/>
<separator string="Notes" colspan="4"/>
<field name="note" nolabel="1" colspan="4"/>
</form>
</field>
</record>
<record id="view_account_report_tree" model="ir.ui.view">
<field name="name">account.report.tree</field>
<field name="model">account.report</field>
<record id="view_account_low_level_report_tree" model="ir.ui.view">
<field name="name">account.low.level.report.tree</field>
<field name="model">account.low.level.report</field>
<field name="type">tree</field>
<field name="arch" type="xml">
<tree string="Account Report">
@ -2740,8 +2741,8 @@ action = self.pool.get('res.config').next(cr, uid, [], context)
</field>
</record>
<record id="view_account_report_search" model="ir.ui.view">
<field name="name">account.report.search</field>
<record id="view_account_low_level_report_search" model="ir.ui.view">
<field name="name">account.low.level.report.search</field>
<field name="model">account.report</field>
<field name="type">search</field>
<field name="arch" type="xml">
@ -2761,17 +2762,17 @@ action = self.pool.get('res.config').next(cr, uid, [], context)
</field>
</record>
<record id="action_account_report_tree" model="ir.actions.act_window">
<record id="action_account_low_level_report_tree" model="ir.actions.act_window">
<field name="name">Account Reports</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">account.report</field>
<field name="res_model">account.low.level.report</field>
<field name="view_type">form</field>
<field name="view_mode">tree,form</field>
<field name="view_id" ref="view_account_report_tree"/>
<field name="search_view_id" ref="view_account_report_search"/>
<field name="search_view_id" ref="view_account_low_level_report_search"/>
<field name="view_id" ref="view_account_low_level_report_tree"/>
</record>
<menuitem id="menu_account_reports_tree" name="Account Reports" parent="menu_account_reports" action="action_account_report_tree"/>
<menuitem id="menu_account_low_level_reports_tree" name="Account Reports" parent="menu_account_reports" action="action_account_low_level_report_tree"/>
<record id="view_account_report_tree_hierarchy" model="ir.ui.view">
<field name="name">account.report.hierarchy</field>

View File

@ -42,7 +42,7 @@ import account_analytic_entries_report
import account_balance_sheet
import account_profit_loss
import account_treasury_report
import account_report_common
import account_low_level_report
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

View File

@ -29,6 +29,8 @@ class report_account_common(report_sxw.rml_parse, common_report_header):
def __init__(self, cr, uid, name, context=None):
super(report_account_common, self).__init__(cr, uid, name, context=context)
self.localcontext.update( {
'get_lines': self.get_lines,
'time': time,
'get_report_details': self._get_report_details,
'get_fiscalyear': self._get_fiscalyear,
@ -90,6 +92,27 @@ class report_account_common(report_sxw.rml_parse, common_report_header):
accounts = [acc for acc in rpt.account_ids if acc.level != 0]
return accounts
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):
vals = {
'name': report.name,
'balance': report.balance,
'type': 'report',
}
lines.append(vals)
if report.type == 'accounts' and report.display_detail:
for account in report.account_ids:
vals = {
'name': account.code + ' ' + account.name,
'balance': account.balance,
'type': 'account',
}
lines.append(vals)
return lines
def get_report_balance(self, child, child_ids, context=None):
cr, uid = self.cr, self.uid
report_obj = self.pool.get('account.report')
@ -109,6 +132,6 @@ class report_account_common(report_sxw.rml_parse, common_report_header):
balance += a.balance
return balance
report_sxw.report_sxw('report.accounting.report', 'account.account',
'addons/account/report/account_report_common.rml', parser=report_account_common, header='internal')
report_sxw.report_sxw('report.account.low.level.report', 'account.low.level.report',
'addons/account/report/account_low_level_report.rml', parser=report_account_common, header='internal')

View File

@ -216,7 +216,7 @@
<para style="Standard">
<font color="white"> </font>
</para>
<para style="Standard">[[ repeatIn(get_report_details(data),'r') ]] </para>
<!--<para style="Standard">[[ repeatIn(get_report_details(data),'r') ]] </para>
<blockTable colWidths="314.0,156.0" style="Table2_Report">
<tr>
<td><para style="terp_default_Bold_9">Report Name</para></td>
@ -226,7 +226,7 @@
<td><para style="terp_default_8">[[ r['name'] ]]</para></td>
<td><para style="terp_default_8">[[ formatLang(r['balance']) ]][[ company.currency_id.symbol ]]</para></td>
</tr>
</blockTable>
</blockTable>-->
<para style="Standard">
<font color="white"> </font>
</para>
@ -247,6 +247,11 @@
</td>
</tr>
<tr style="Table3">
[[ repeatIn(get_lines(r['id'], data), 'a') ]]
<td>[[a.name]]</td>
<td>[[a.balance]]</td>
<!--
[[ repeatIn(get_account_details(r['id'], data), 'a') ]]
[[ setTag('tr','tr',{'style': 'Table'+str(min(3,a.level))}) ]]
<td><para style="terp_level_3_code">[[ (a.type =='view' and a.level &gt;= 3) and setTag('para','para',{'style': 'terp_level_3_code_bold'}) or setTag('para','para',{'style': 'terp_level_'+str(min(3,a.level))+'_code'}) ]]<i>[[ a.code ]]</i></para></td>
@ -255,6 +260,7 @@
<td>[[ a.level == 2 or removeParentNode('td') ]]<para style="terp_level_2_balance"><u>[[ formatLang(a.balance) ]] [[company.currency_id.symbol ]]</u></para></td>
<td>[[ get_filter(data)!='No Filter' and (a.level &lt;&gt;2) or removeParentNode('td') ]]<para style="terp_level_3_balance">[[ (a.type =='view' and a.level &gt;= 3) and setTag('para','para',{'style': 'terp_level_3_balance_bold'}) or setTag('para','para',{'style': 'terp_level_'+str(min(3,a.level))+'_balance'}) ]][[ formatLang(a.balance) ]] [[company.currency_id.symbol ]]</para></td>
<td>[[ get_filter(data)!='No Filter' and a.level == 2 or removeParentNode('td') ]]<para style="terp_level_2_balance"><u>[[ formatLang(a.balance) ]] [[company.currency_id.symbol ]]</u></para></td>
-->
</tr>
</blockTable>
<para style="Standard">

View File

@ -47,7 +47,7 @@ import account_open_closed_fiscalyear
import account_invoice_state
import account_chart
import account_tax_chart
import account_report
import account_low_level_report
#TODO: remove this file no moe used
# also remove related view fiel

View File

@ -29,10 +29,22 @@ 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 Report', required=True),
'label_filter': fields.char('Filters Label', size=32, help="This label will be displayed on report to show the balance computed for the given comparison filter."),
'account_report_id': fields.many2one('account.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),
'period_from_cmp': fields.many2one('account.period', 'Start Period'),
'period_to_cmp': fields.many2one('account.period', 'End Period'),
'date_from_cmp': fields.date("Start Date"),
'date_to_cmp': fields.date("End Date"),
}
_defaults = {
'filter_cmp': 'filter_no',
'target_move': 'posted',
}
def _print_report(self, cr, uid, ids, data, context=None):
#TODO: must read new fields, for comporison. Maybe better to do it at the end of check method
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',
@ -42,4 +54,4 @@ class accounting_report(osv.osv_memory):
accounting_report()
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

View File

@ -8,25 +8,22 @@
<field name="type">form</field>
<field name="inherit_id" ref="account.account_common_report_view"/>
<field name="arch" type="xml">
<xpath expr="//field[@name='fiscalyear_id']" position="replace">
</xpath>
<xpath expr="//field[@name='target_move']" position="replace">
<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="replace">
<page string="Filters" attrs="{'invisible': [('enable_filter','=',False)]}">
<field name="fiscalyear_id"/>
<field name="target_move"/>
<field name="filter" on_change="onchange_filter(filter, fiscalyear_id)"/>
<field name="label_filter"/>
<xpath expr="//notebook/page[@string='Filters']" position="after">
<page string="Comparison" attrs="{'invisible': [('enable_filter','=',False)]}">
<field name="label_filter" attrs="{'required': [('enable_filter', '=', True)]}"/>
<field name="fiscalyear_id_cmp"/><newline/>
<field name="filter_cmp" on_change="onchange_filter(filter, fiscalyear_id)"/>
<separator string="Dates" colspan="4"/>
<field name="date_from" attrs="{'readonly':[('filter', '!=', 'filter_date')], 'required':[('filter', '=', 'filter_date')]}" colspan="4"/>
<field name="date_to" attrs="{'readonly':[('filter', '!=', 'filter_date')], 'required':[('filter', '=', 'filter_date')]}" colspan="4"/>
<field name="date_from_cmp" attrs="{'readonly':[('filter_cmp', '!=', 'filter_date')], 'required':[('filter_cmp', '=', 'filter_date')]}" colspan="4"/>
<field name="date_to_cmp" attrs="{'readonly':[('filter_cmp', '!=', 'filter_date')], 'required':[('filter_cmp', '=', 'filter_date')]}" colspan="4"/>
<separator string="Periods" colspan="4"/>
<field name="period_from" domain="[('fiscalyear_id', '=', fiscalyear_id)]" attrs="{'readonly':[('filter','!=','filter_period')], 'required':[('filter', '=', 'filter_period')]}" colspan="4"/>
<field name="period_to" domain="[('fiscalyear_id', '=', fiscalyear_id)]" attrs="{'readonly':[('filter','!=','filter_period')], 'required':[('filter', '=', 'filter_period')]}" colspan="4"/>
<field name="period_from_cmp" domain="[('fiscalyear_id_cmp', '=', fiscalyear_id)]" attrs="{'readonly':[('filter_cmp','!=','filter_period')], 'required':[('filter_cmp', '=', 'filter_period')]}" colspan="4"/>
<field name="period_to_cmp" domain="[('fiscalyear_id_cmp', '=', fiscalyear_id)]" attrs="{'readonly':[('filter_cmp','!=','filter_period')], 'required':[('filter_cmp', '=', 'filter_period')]}" colspan="4"/>
</page>
</xpath>
<xpath expr="//notebook/page[@string='Journals']" position="replace">