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.

0

Error occurred while validating the field(s) arch: Invalid XML for View Architecture!'

By
Hachem Chraiti
on 4/4/14, 5:18 PM 2,604 views

im using inheritance betwenn two classe

base class: from openerp.osv import fields, osv

class test_base(osv.osv): _name='test.base' _columns={ 'name':fields.char('Name'), 'email':fields.char('Email'),

    'code':fields.integer('Unique ID'),
    'sal':fields.float('Salary'),
    'rate':fields.selection(((10,'10'), (20,'20'),(30,'30')),
           'Percentage of Deduction'),
    'ded':fields.float('Deduction'),
    'bdisplay':fields.float('Button Display'),

}

def on_change_ded_cal(self, cr, uid, ids,rate,context=None):
    x=rate*2
    return {'value':{'ded':x }}

test_base()

----base xml file

<openerp> <data>

    <record model="ir.ui.view" id="test_base_form">
        <field name="name">test.base.form</field>
        <field name="model">test.base</field>
        <field name="arch" type="xml">
            <form string="Test Base" version="7.0">
                <group col="4">
                    <field name="name" />
                    <field name="email" />
                    <field name="code" />
                    <field name="sal" />
                    <field name="rate" on_change="on_change_ded_cal(rate)" />
                    <field name="ded" />
                    <field name="bdisplay" />
                </group>
            </form>
        </field>
    </record>
    <record model="ir.ui.view" id="test_base_tree">
        <field name="name">test.base.tree</field>
        <field name="model">test.base</field>
        <field name="type">tree</field>
        <field name="arch" type="xml">
            <tree string="Test Base">
                <field name="name" />
                <field name="email" />
                <field name="code" />
                <field name="sal" />
                <field name="ded" />
            </tree>
        </field>
    </record>
    <record model="ir.actions.act_window" id="action_pos_base">
        <field name="name">Test Base</field>
        <field name="res_model">test.base</field>
        <field name="view_type">form</field>
        <field name="view_mode">tree,form</field>
        <field name="view_id" ref="test_base_tree" />
        <field name="context">{"search_default_filter_see_all":1}</field>
        <field name="help" type="html">

            Click here to create a universities for
            Hachem.
        </field>
    </record>



    <menuitem name="Faculty Management" id="menu_point_root"
        sequence="30" />

    <menuitem name="TestBase Menu" id="action_pos_bases"
        parent="menu_point_root" sequence="20" />
    <menuitem id="menu_action_pos_base" parent="action_pos_bases"
        action="action_pos_base" />

</data>

</openerp>

---inherited class

from openerp.osv import fields, osv

class my_base(osv.osv): _name='my.base' _inherit='test.base' _columns={ 'dept':fields.char('Department'),
}

my_base()

---its xml view

<openerp> <data>

    <record model="ir.ui.view" id="test_base_tree_inherit">
        <field name="name">test.base.tree</field>
        <field name="model">test.base</field>
        <field name="type">tree</field>
        <field name="inherit_id2" ref="TestModuleHachem.test_base_tree" />
        <field name="arch" type="xml">
            <field name="dept" />
        </field>
    </record>

</data>

</openerp>

why im having this erroorr!!!!! the debug : except_orm: ('View error', u"Can't find field 'dept' in the following view parts composing the view of object model 'test.base':\n * test.base.tree\n\nEither you wrongly customized this view, or some modules bringing those views are not compatible with your current data model") 2014-04-04 19:05:55,439 16131 ERROR procan openerp.tools.convert: Parse error in /home/hachem/development/openerp/7.0/openerp/addons/TestModuleHachem/mybase.xml:5:

0
Serge
On 4/4/14, 5:28 PM
<record model="ir.ui.view" id="test_base_tree_inherit">
        <field name="name">test.base.tree</field>
        <field name="model">test.base</field>
        <field name="type">tree</field>
        <field name="inherit_id2" ref="TestModuleHachem.test_base_tree" />
        <field name="arch" type="xml">
            <field name="ded" position="after">
                  <field name="dept" />
            </field>
        </field>
    </record>

</data>

You need to tell WHERE you wanna add your field when you inherit a view.

When you inherit DONT change the object name.

 class my_base(osv.osv):
     #######_name='my.base' 
     _inherit='test.base' 
     _columns={ 'dept':fields.char('Department'),  }
 my_base()

and i would like to not inherit all columns(inherit some columns not all of them) ?how can i do this?

Hachem Chraiti
on 4/4/14, 6:23 PM

_inherit = 'test.base' : means that you will just add the field 'dept' in the table test_base and not creating a new table. this is where your data field is recorded.

Med Said BARA
on 4/4/14, 6:45 PM

If you wanna create a new object with only some columns from base ... dont inherit create a real new object. And if you need some fields, you can create a many2one to the base object, and after create some related fields.

Serge
on 4/7/14, 10:45 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

1 follower(s)

Stats

Asked: 4/4/14, 5:18 PM
Seen: 2604 times
Last updated: 3/16/15, 8:10 AM