Skip ke Konten
Menu
Pertanyaan ini telah diberikan tanda
2 Replies
11411 Tampilan

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>

Avatar
Buang
Jawaban Terbai

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

Avatar
Buang
Penulis

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.

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.

Penulis

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) }

Jawaban Terbai

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

Avatar
Buang
Penulis

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) }

did u got the output

Can please post your screenshot of your error

Penulis

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

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

Penulis

Thanks its now working

Post Terkait Replies Tampilan Aktivitas
5
Agu 24
47637
2
Apr 24
3132
3
Jun 23
7076
2
Jun 23
5436
3
Mar 23
10889