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 "Invalid XML for View Architecture" in custom form view

By
mmycool
on 2/19/13, 5:19 AM 7,569 views

Hello, I am starting developing openerp modules. What could be wrong with the following code:

school.py

from openerp.osv import osv,fields

class school(osv.osv):
    _name = "school"
    _description = "This will hold the school information"
    _columns = {
        'school_name': fields.char('School Name', size=30,required=True),
        'address': fields.char('Postal Address', size=50 , required=True),
        'city': fields.char('City', size=30, required=True),
                }

school()

school_view.xml

<?xml version="1.0" encoding="utf-8"?>
<openerp>
    <data>
        <record model="ir.ui.view" id="school_base_form">
            <field name="name">school.form</field>
            <field name="model">school.school</field>
            <field name="type">form</field>
            <field name="arch" type="xml">
                <form string="School">
                    <field name="school_name"/>
                    <field namme="address"/>
                    <field name="city"/>
                </form>
            </field>
    </record>

        <record model="ir.actions.act_window" id="action_school_form">
            <field name="name">school</field>
            <field name="res_model">school.school</field>

        </record>
    <menuitem name="School Management" id="school_menu" />
    <menuitem name="Schools" parent="school_menu" id="schools_menu" action="action_school_form" />
    </data>
</openerp>

I am getting the error: ValidateError Error occurred while validating the field(s) arch: Invalid XML for View Architecture!

What could be the problem?

Daniel Reis
on 2/19/13, 6:17 AM

Corrected as per this question but still it doesn't work.

mmycool
on 2/19/13, 6:36 AM

Look at my answer, either you did not change the post or you still have the same problem. _name in .py, model in view definition and res_model in action definition should all be te same!

Lucio
on 2/19/13, 10:08 AM
2
Lucio
On 2/19/13, 7:51 AM

Your model is called just school not school.school.

Change:

<field name="res_model">school.school</field>

for:

<field name="res_model">school</field>

and in the view change:

<field name="model">school.school</field>

for:

<field name="model">school</field>

Or you can just change, in the .py

_name = "school"

for:

_name = "school.school"

And it should work!

Hope it fix your problem!

0

Andreas Brueckl

--Andreas Brueckl--
5056
| 7 8 7
Vienna, Austria
--Andreas Brueckl--
OpenERP Consulting and Development
Andreas Brueckl
On 2/19/13, 6:56 AM

you should remove the line

<field name="type">form</field>

Also line

<field namme="address"/>

should be replaced by

<field name="address"/>

In the log file normally there is a more detailed description of the error.

Done that...still the same problem.

mmycool
on 2/19/13, 6:57 AM
0
mmycool
On 2/19/13, 4:22 PM

The code:

from openerp.osv import osv,fields

class school(osv.osv):
    _name = "school"
    _description = "school information"
    _columns = {
        'school_name': fields.char('School Name', size=30,required=True),
        'address': fields.char('Postal Address', size=50 , required=True),
        'city': fields.char('City', size=30, required=True),
    }

school()

and the view:

<?xml version="1.0" encoding="utf-8"?>
    <openerp>
    <data>
        <record model="ir.ui.view" id="school_base_form">
            <field name="name">school.form</field>
            <field name="model">school</field>
            <field name="arch" type="xml">
                <form string="School" version="7.0">
                    <field name="school_name"/>
                    <field name="address"/>
                    <field name="city"/>
                </form>
            </field>
    </record>

        <record model="ir.actions.act_window" id="action_school_form">
            <field name="name">school</field>
            <field name="res_model">school</field>

        </record>
<menuitem name="School Management" id="school_menu" />
<menuitem name="Schools" parent="school_menu" id="schools_menu" action="action_school_form" />
</data>
</openerp>

The same error... Where is the damn bug?

I tried your given code and it's working fine without any error.

Sudhir Arya (SA)
on 2/20/13, 12:36 AM

It works....after restarting openerp! Thank you all for your assistance.

mmycool
on 2/20/13, 4:34 PM
0

saad

--saad--
1008
| 5 4 8
Casablanca, Morocco
--saad--
saad
On 2/19/13, 7:18 AM

res_model in action should have the same model name.

<field name="res_model">school</field>
0
Lebbar
On 7/16/13, 7:14 AM

I had the same problem today. I think the xml parser cannot understand lines like:

<field name="adress"/>

You should try:

<field name="address" />

Look at the space before the / ...

I hope that solves your problem :-)

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: 2/19/13, 5:19 AM
Seen: 7569 times
Last updated: 3/16/15, 8:10 AM