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

Problem with many to one field

By
Praveen S
on 7/5/13, 3:55 AM 2,796 views

hi, When me tried to add a many 2 one field in my module it will generates the following error while me tried to install that module.

ERROR:

ValidateError

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

And my files are,

region.py

from openerp.osv import osv, fields class region(osv.Model): _name = 'region.region' _columns = { 'name': fields.char('Name', size = 100), 'type': fields.selection([('country','Country'),('state','State')],'Type'),
'country': fields.many2one('res.country', 'Country'), }

And my view file is

region_view.xml

<openerp> <data> <menuitem id="region_main_menu" name="Regions"/>

 <record id="region_region_tree_view" model="ir.ui.view">
    <field name="name">region.region.tree</field>
    <field name="model">region.region</field>
    <field name="arch" type="xml">
        <tree string="Regions">
            <field name="name"/>
            <field name="type"/>
            <field name="country"/>
        </tree>
    </field>
</record>

<record id="region_region_form_view" model="ir.ui.view">
    <field name="name">region.region.form</field>
    <field name="model">region.region</field>
    <field name="arch" type="xml">
        <form string="regions" version="7.0">
            <group col="4" colspan="4">
                <field name="name"/>
                <field name="type"/>
                <field name="country"/>
            </group>
       </form>
    </field>
</record>

<record id="region_normal_action" model="ir.actions.act_window">
    <field name="name">region</field>
    <field name="res_model">region.region</field>
    <field name="view_type">form</field>
    <field name="view_mode">tree,form</field>
</record>

<menuitem id="section_main_menu" parent="region_main_menu" name = "Region Information"/>
<menuitem id="region_real_menu" parent="section_main_menu" action="region_normal_action"/>

</data> </openerp>

3
Sreedath Namangalam
On 7/5/13, 4:47 AM

I have tried doing the same thing in my OpenERP client. The code is worked fine.

Python

from openerp.osv import osv,fields

class region(osv.Model):
    _name = 'region.region'
    _columns = { 
                'name': fields.char('Name', size = 100), 
                'type': fields.selection([('country','Country'),('state','State')],'Type'), 
                'country': fields.many2one('res.country', 'Country'), 
            }
region()

xml

<openerp> 
<data> 
    <menuitem id="region_main_menu" name="Regions"/>
    <record id="region_region_tree_view" model="ir.ui.view">
        <field name="name">region.region.tree</field>
        <field name="model">region.region</field>
        <field name="arch" type="xml">
            <tree string="Regions">
                <field name="name"/>
                <field name="type"/>
                <field name="country"/>
            </tree>
        </field>
    </record>

    <record id="region_region_form_view" model="ir.ui.view">
        <field name="name">region.region.form</field>
        <field name="model">region.region</field>
        <field name="arch" type="xml">
            <form string="regions" version="7.0">
                <group col="4" colspan="4">
                    <field name="name"/>
                    <field name="type"/>
                    <field name="country"/>
                </group>
           </form>
        </field>
    </record>

    <record id="region_normal_action" model="ir.actions.act_window">
        <field name="name">region</field>
        <field name="res_model">region.region</field>
        <field name="view_type">form</field>
        <field name="view_mode">tree,form</field>
    </record>

<menuitem id="section_main_menu" parent="region_main_menu" name = "Region Information"/>

<menuitem id="region_real_menu" parent="section_main_menu" action="region_normal_action"/>

</data>

</openerp>

I am attaching the form and tree view of the same. Please check it also. C:\fakepath\form_view.png C:\fakepath\tree_view.png

Thanks

Sreedath

Hi Sreedath, Thanks for your replay. I didn't get the result. Is their any problem with my code. If you know pls help me. And pls give your work files.

Praveen S
on 7/5/13, 5:04 AM

I have posted the codes. You have to add import filename.py to the _init_ file and add the filename_view.xml to the openerp file. thats all. no other errors there in the code.

Sreedath Namangalam
on 7/5/13, 5:08 AM

i already done it but no result,

my files are

__init__.py import region __openerp__.py { 'name': 'Region information', 'version': '2.0', 'author': 'Praveen', 'depends': ['base'], 'data': [ # data files to load at module install 'region_view.xml', ], 'demo': [], # demo data (for unit tests) }

Praveen S
on 7/5/13, 5:13 AM
3
PARVATHY VIJAYAN P
On 7/5/13, 4:42 AM

I have tested your code and got the output without error.I think you should check your init file and openerp file in your module, whether the file are correctly defined in it

Thanks

Parvathy

Hai Parvathy, Thanks for your replay But its not working for me my init and openerp file are here

__init__.py import region

__openerp__.py

{ 'name': 'Region information', 'version': '2.0', 'author': 'Praveen', 'depends': ['base'], 'data': [ # data files to load at module install 'region_view.xml',
], 'demo': [], # demo data (for unit tests) }

Praveen S
on 7/5/13, 4:48 AM

did u got the output

PARVATHY VIJAYAN P
on 7/5/13, 4:50 AM

Can please post your screenshot of your error

PARVATHY VIJAYAN P
on 7/5/13, 4:57 AM

i didn't get the output because of <30 karma i cant add the screenshot. when me tried to install this module i got the following error ValidateError

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

Are you know any solution to this problem

Praveen S
on 7/5/13, 5:04 AM

Your code is perfectly correct.Did you restart your server and updated the module, after that update the module list in settings and then install your module. -u module_name -d db_name

PARVATHY VIJAYAN P
on 7/5/13, 5:15 AM

Thanks its now working

Praveen S
on 7/5/13, 5:35 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: 7/5/13, 3:55 AM
Seen: 2796 times
Last updated: 3/16/15, 8:10 AM