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

Can't install custom module -> arch: Invalid XML for View Architecture!

By
Amre MAARIR
on 11/2/15, 9:36 AM 572 views

Hello everyone,

I'm trying to create a custom module that can add fields to an existing view. I followed this tutorial to create the module : http://www.pixelite.co.nz/article/adding-additional-fields-using-custom-module-openerp-7/ but i get an error when i try to install it : arch: Invalid XML for View Architecture!

I'm using OpenERP 7 on Windows 7.

This is my module configuration:

  • __init__.py

import demo
  • __openerp__.py

{
"name": "Demo module",
"version": "0.2",
"author": "Amre",
"category": "Demo",
"depends": ["base"],
"demo": [],
"data": ["demo_view.xml"],
"installable": True,
}
  • demo.py

from openerp.osv import osv, fields


class demo(osv.osv):
_inherit = "res.partner"

_columns = {
'demo_id': fields.integer('Demo ID', size=11),
}

_defaults = {
'demo_id': 0
}


demo()
  • demo_view.xml

<?xml version="1.0"?>
<openerp>
<data>
<record model="ir.ui.view" id="demo_view_form">
<field name="name">res.partner.form</field>
<field name="model">res.partner</field>
<field name="inherit_id" ref="base.view_partner_form"/>
<field name="arch" type="xml">
<xpath expr="/form/sheet/group/group/field[@name='website']" position="after">
<field name="demo_id"/>
</xpath>
</field>
</record>
</data>
</openerp>

This module example needs to add a field called "demo_id" to the existing view "base.view_partner_form".


Thanks a lot for you effort and your help.


EDIT 1 : I corrected the xpath with "form", but i still get the same error.

EDIT 2 : made corrections suggested by Akhil P Sivan, i still get the same error again :(

EDIT 3 : made corrections suggested by Temur,the code now works like a charm :D. Good job guys !

1

Temur

--Temur--
2894
| 6 5 7
Tbilisi, Georgia
--Temur--
Programmer
Temur
On 11/2/15, 10:28 AM

You can use partial path:

<xpath expr="//group/group/field[@name='website']" position="after">
<field name="demo_id"/>
</xpath>

UPDATE:

added missing apostrophe to the above code. it should work now.

Thanks for the feedback, i tried your code but i still get the same error :s

Amre MAARIR
on 11/2/15, 10:40 AM

Sorry, there were missing ' after website in xpath.. (perhaps I copied it from the question). I updated answer, try now please

Temur
on 11/2/15, 11:00 AM

GREAT !! it works.. thanks a lot buddy you really helped me.

Amre MAARIR
on 11/2/15, 11:16 AM

You're welcome

Temur
on 11/3/15, 2:45 AM
1

Akhil P Sivan

--Akhil P Sivan--
3423
| 5 3 6
Kochi, India
--Akhil P Sivan--

Interested in exploring Odoo both technically & functionality wise.

email-id : akhilpsivan01@gmail.com

Akhil P Sivan
On 11/2/15, 10:33 AM

Remove duplicate occurrence of "data" in your __openerp__.py file. Also _columns and _defaults are different dictionaries. Put the closing brace of _columns before _defaults.  

Keep .py file like this:

from openerp.osv import osv, fields


class demo(osv.osv):
 
_inherit = "res.partner"

_columns = {
'demo_id': fields.integer('Demo ID', size=11),
              }

_defaults = {
'demo_id': 0
}


demo()

Because you wrongly typed form in your xpath expression:

<xpath expr="/form/sheet/group/group/field[@name='website']" position="after">
<field name="demo_id"/>
</xpath>

Thanks for the tip, but still getting the same error.

Amre MAARIR
on 11/2/15, 10:42 AM

Thanks a lot for your help, and sorry for those mistakes i'm new to module developement. Unfortunatly i made all the corrections but i still have the same error !!

Amre MAARIR
on 11/2/15, 11:03 AM
0
Amre MAARIR
On 11/2/15, 10:41 AM

Thanks for your feedback,

i tried both solutions but i still get the same error when i try to install the module. :\


UPDATE : It works now !! the xpath expression was missing an apostrophe. Thanks a lots to Temur and to Akhil P Sivan for your effort.


Make those corrections in updated answer n try

Akhil P Sivan
on 11/2/15, 10:47 AM

Did you check after the corrections?

Akhil P Sivan
on 11/2/15, 10:53 AM

Thanks a lot for your help, and sorry for the mistakes i'm new to module développement.
I made all the corrections but I still get the same error :(

Le 2 nov. 2015 15:53, "Akhil P Sivan" <akhilpsivan01@gmail.com> a écrit :

Did you check after the corrections?

--
Akhil P Sivan
Sent by Odoo S.A. using Odoo access your messages
Amre MAARIR
on 11/2/15, 11:07 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: 11/2/15, 9:36 AM
Seen: 572 times
Last updated: 11/2/15, 11:28 AM