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.

1

attribute error in inherited view?

By
evon_dun
on 5/2/13, 8:00 AM 2,697 views

I added a new module that depends on base module, and my model inherits res.partner, i need to add two fields: customer reference and reference type, i did that the way it should be but there is an error that has really irritated me. The error is:

`AttributeError: View definition error for inherited view 'reference.customer_reference_form' on model 'res.partner': Element '<field name="reference_name">' not found in parent view '%(parent_xml_id)s'.`

My reference.py file:

from osv import osv,fields
import decimal_precision as dp
import netsvc
import time
from datetime import date
import pooler

class res_partner_reference(osv.osv):
    _name = 'res.partner'
    _inherit = 'res.partner'
    _columns = {
                'reference_name':fields.char('Reference',required=True,size=64,help="Name of the person who refered the customer"),
                'category':fields.selection([('none','None'),('painter','Painter'),('carpenter','Carpenter'),('supplier','Supplier')],'Type of Reference', required=True, help="To describe Reference"),
                }
res_partner_reference()

and my view:

<?xml version="1.0" encoding="UTF-8"?>
<openerp>
    <data>
        <record id="customer_reference_form" model="ir.ui.view">
            <field name="name">res.partner.form.inherit</field>
            <field name="model">res.partner</field>
            <field name="inherit_id" ref="base.view_partner_form" />
            <field name="arch" type="xml">
                <data>
                    <field name="name" position="after"/>
                    <field name="reference_name"/>
                    <field name="category"/>
                </data>
            </field>
        </record>
        <!-- <record id="customer_reference_tree" model="ir.ui.view">
            <field name="name">res.partner.tree.inherit</field>
            <field name="model">res.partner</field>
            <field name="inherit_id" ref="base.view_partner_tree" />
            <field name="arch" type="xml">            
                <data>
                    <field name="name" position="after"/>
                    <field name="ref_name"/>                    
                    <field name="category"/>
                </data>
            </field>
        </record> -->
        <record model="ir.actions.act_window" id="action_reference_form">
            <field name="name">Customer References</field>
            <field name="res_model">res.partner</field>
        </record>

        <menuitem name="References" id="menu_sale_references" parent="base.menu_sales" sequence="5" action="action_reference_form" />
        <menuitem name="Customer References" id="menu_account_references" parent="account.menu_finance" sequence="3" action="action_reference_form" />
    </data>
</openerp>

Kindly help its urgent.

4

Sudhir Arya (SA)

--Sudhir Arya (SA)--
10150
| 6 8 8
Ahmedabad, India
--Sudhir Arya (SA)--

Working as an OpenERP/Odoo developer and a Team Leader 

Top 5 Odoo contributor On Stackoverflow

LinkedIn

Blog

Stackoverflow

Sudhir Arya (SA)
On 5/2/13, 8:15 AM

Problem is in your syntax while giving position.

Try this:

    <record id="customer_reference_form" model="ir.ui.view">
        <field name="name">res.partner.form.inherit</field>
        <field name="model">res.partner</field>
        <field name="inherit_id" ref="base.view_partner_form" />
        <field name="arch" type="xml">
            <data>
                <field name="name" position="after">
                    <field name="reference_name"/>
                    <field name="category"/>
                </field>
            </data>
        </field>
    </record>

This will work for sure.

Thank you

evon_dun
on 5/2/13, 8:34 AM
0

Francesco OpenCode

--Francesco OpenCode--
3608
| 5 7 9
Grottaglie, Italy
--Francesco OpenCode--

Italian Odoo (OpenERP) Modules Developer LINKEDIN: http://www.linkedin.com/in/francescoapruzzese

Francesco OpenCode
On 5/2/13, 8:15 AM

This code:

<data>
    <field name="name" position="after"/>
    <field name="reference_name"/>
    <field name="category"/>
</data>

Must be:

<data>
    <field name="name" position="after">
        <field name="reference_name"/>
        <field name="category"/>
    </field>
</data>

Thanks a lot i couldn't figure this out even i made a same kind of module earlier.

evon_dun
on 5/2/13, 8:20 AM

If the answer is the correct one please cheack it as correct to help future user searches!

Francesco OpenCode
on 5/2/13, 8:24 AM

One more question I want to use these two fields in sale order view too, do i need to create a new sales order view in my view or i can do it in sale.py and sales_view.xml??

evon_dun
on 5/2/13, 9:44 AM

If you want the some fields in sale order you must inherith sale.order class, insert the some field and inherit sale_order view, too. The some field can't be used in different classes.

Francesco OpenCode
on 5/2/13, 11:28 AM

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

0 follower(s)

Stats

Asked: 5/2/13, 8:00 AM
Seen: 2697 times
Last updated: 3/16/15, 8:10 AM