Here is a workaround. At least for me :). Hope it helps others.
I made a custom module which adds the parent_id field from analytic account to the analytic entries report.
__init__.py
import account_analytic_entries_report
__openerp__.py
{
'name': 'Accana report Parent',
'version': '1.1',
'description': '''
* Add *parent_id* to the model, sql query and tree view
''',
'depends': ['base', 'account'],
'init_xml': [],
'update_xml': ['account_analytic_entries_report_view.xml'],
'demo_xml': [],
'test': [],
'installable': True,
'auto_install': True,
'active': False,
'certificate': '',
}
account_analytic_entries_report.py
from openerp import tools
from openerp.osv import fields,osv
class analytic_entries_report(osv.osv):
_inherit = 'analytic.entries.report'
_columns = {
'parent_id': fields.many2one('account.analytic.account', 'ParentAcc', required=False),
}
def init(self, cr):
tools.drop_view_if_exists(cr, 'analytic_entries_report')
cr.execute("""
create or replace view analytic_entries_report as (
select
min(a.id) as id,
count(distinct a.id) as nbr,
a.date as date,
to_char(a.date, 'YYYY') as year,
to_char(a.date, 'MM') as month,
to_char(a.date, 'YYYY-MM-DD') as day,
a.user_id as user_id,
a.name as name,
analytic.partner_id as partner_id,
analytic.parent_id as parent_id,
a.company_id as company_id,
a.currency_id as currency_id,
a.account_id as account_id,
a.general_account_id as general_account_id,
a.journal_id as journal_id,
a.move_id as move_id,
a.product_id as product_id,
a.product_uom_id as product_uom_id,
sum(a.amount) as amount,
sum(a.unit_amount) as unit_amount
from
account_analytic_line a, account_analytic_account analytic
where analytic.id = a.account_id
group by
a.date, a.user_id,a.name,analytic.partner_id,analytic.parent_id,a.company_id,a.currency_id,
a.account_id,a.general_account_id,a.journal_id,
a.move_id,a.product_id,a.product_uom_id
)
""")
analytic_entries_report()
account_analytic_entries_report_view.xml
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<record id="view_analytic_entries_report_tree_svt1" model="ir.ui.view">
<field name="name">analytic.entries.report.tree_svt1</field>
<field name="model">analytic.entries.report</field>
<field name="inherit_id" ref="account.view_analytic_entries_report_tree"/>
<field name="arch" type="xml">
<field name="partner_id" position="after">
<field name="parent_id" invisible="1"/>
</field>
</field>
</record>
</data>
</openerp>
Good question!
I have a similar situation. One parent, 3 child accounts with several sub accounts. I want to see in the first case the totals on parent, and after the totals on child accounts. Any idea? Thanks!