Odoo Help

Welcome!

This community is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

3

How to analyse on parent analytic account?

By
Endian Solutions B.V.
on 8/20/13, 6:32 AM 1,557 views

I have created several analytic accounts and the all have the same parent. When i go to Reporting > Accounting > Analytic Entries Analysis, I see only analytic data from my analytic accounts. But how can i see the totals on the parent analytic account?

Thanks for the help.

Good question!

Daniel Reis
on 8/20/13, 8:22 AM

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!

Tekse Arpad
on 1/29/14, 8:10 AM
0
Tekse Arpad
On 1/30/14, 7:20 AM

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>

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

4 follower(s)

Stats

Asked: 8/20/13, 6:32 AM
Seen: 1557 times
Last updated: 3/16/15, 8:10 AM