Odoo Help

0

context passing non existing fields?

By
Raffaele
on 3/9/15, 7:33 AM 1,321 views

In Odoo v8, with analytic accounting and contracts management enabled, I override the searchview for Contracts to group them by parent analytic account: in the contract view, when I click on "invoices" - that redirects me to the sale.order.line.tree of invoices for that Contract - I get an error regarding the "parent_id", that actually doesn't exist in the Sale Order Line model.

These are my modifications. The Searchview

<record id="analytic_account_redefine_searchview" model="ir.ui.view" forcecreate="1">
            <field name="name">analytic.account.redefine.searchview</field>
            <field name="model">account.analytic.account</field>
            <field name="inherit_id" ref="account_analytic_analysis.view_account_analytic_account_overdue_search" />
            <field name="arch" type="xml" >

                <xpath expr="//filter[@string='Status']" position="before">
                    <filter name="category" string="Parent account" domain="[]" context="{'group_by':'parent_id'}"/>
                </xpath>

            </field>
        </record>

The window action

<record id="account_analytic_analysis.action_account_analytic_overdue_all" model="ir.actions.act_window">
            <field name="search_view_id" ref="lawyers_analytic_account.analytic_account_redefine_searchview" />
                <field name="context">{
                'default_type':'contract',
                'search_default_open':1, 
                'search_default_pending':1,
                'default_manager_id':uid,
                'search_default_category':1
                }
            </field>

</record>

When I remove the "search_default_category:1" rule, the error disappears.

How could I restrict that context entry so that it gets applied to Contracts only?

@Vasanth: thank you for replying but that doesn't solve

Raffaele
on 3/9/15, 11:31 AM
0
Vasanth
On 3/9/15, 8:22 AM

 Hi, replace the code by the following codes:

    <record id="analytic_account_redefine_searchview" model="ir.ui.view" forcecreate="1">
                <field name="name">analytic.account.redefine.searchview</field>
                <field name="model">account.analytic.account</field>
                <field name="inherit_id" ref="account_analytic_analysis.view_account_analytic_account_overdue_search" />
                <field name="arch" type="xml" >
                <field name="parent_id invisible="1'"/>

                <xpath expr="//filter[@string='Status']" position="before">
                      <filter string="Parent account" domain="[]" context="{'group_by':'parent_id'}"/>
                </xpath>

                </field>
            </record>

 

    <record id="account_analytic_analysis.action_account_analytic_overdue_all" model="ir.actions.act_window">
                <field name="search_view_id" ref="lawyers_analytic_account.analytic_account_redefine_searchview" />
                    <field name="context">{
                    'default_type':'contract',
                    'search_default_open':1,
                    'search_default_pending':1,
                    'default_manager_id':uid,
                    'search_default_parent_id':1
                    }
                </field>

    </record>

Hi Vasanth, thank you for replying and excuse me for delay - I thought I already replied but now I found I didn't. The modifications you suggest don't get any effect. Actually, the problem is not that the "parent_id" is missing from the "parent" model (the contract, alas the analytic account), but that the invoices view tries to inherit filters from the analytic account search view, which instead acts on different fields.

Raffaele
on 4/3/15, 12:20 PM

About This Community

This platform 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.

Register

Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now

Question tools

2 follower(s)

Stats

Asked: 3/9/15, 7:33 AM
Seen: 1321 times
Last updated: 4/27/16, 6:34 AM