Skip to Content
Menu
This question has been flagged
5 Replies
12061 Views

Hi,

I'm trying to add another column on the Product Tree View by using a module.

However, I'm receiving this error message: except_orm: ('ValidateError', u'Error occurred while validating the field(s) arch: Invalid XML for View Architecture!')

This is what I got so far,

__openerp__.py => I already added 'product' on the 'depends' field.

mymodule.py =>

class custom_products(osv.osv):
    _name = "product.product"
    _inherit = "product.product"
    _columns = {
        'asupplier_code': fields.char('Supplier Code',size=32),
    }
    _defaults = {
        'asupplier_code': '-',
    }
custom_products();

mymodule_view.xml =>

<record model="ir.ui.view" id="attempt_2_form">
    <field name="name">product.product.tree</field>
    <field name="model">product.product</field>
    <field name="type">tree</field>
    <field name="inherit_id" ref="product.product_product_tree_view"/>
    <field name="arch" type="xml">
        <field name="default_code" position="after">
            <field name="assupplier_code"/>
        </field>
    </field>
</record>

From what I understand, (when trying to create a module that will edit an existing view)

<field name="name">product.product.tree</field> : I got the value from the View Name field

<field name="model">product.product</field> : I got it from the Object field

<field name="inherit_id" ref="product.product_product_tree_view"/> : The ref would be the name of the view that I wish to inherit right?

Is there something wrong with my understanding and code that results with a Invalid XML for View Architecture?

Thanks!

Avatar
Discard
Author

I finally found what's wrong. The field name has an extra 's'.

Author

still not fixed though.

Best Answer

In odoo 9 (in you have you odoo server in other directory, just change the path to you odoo directory installation)

Create a new custom module:

cd /odoo/odoo-server <--Here inside is the odoo.py script to create a new custom module.

sudo ./odoo.py scaffold myproductviewtreelist /odoo/custom/addons <--This is my directory for my custom modules, this code create a new custom module

cd /odoo/custom/addons/myproductviewtreelist

Edit  __openerp__.py and save this settings:

locate: 'depends': ['base'], and add 'sale' like this:

'depends': ['base','sale'],

Edit emplates.xml and save this settings:

add this code: <--In my case a just want add the default_code field but you can add any field from your product form.

<record id="my_view_products_tree_inherit" model="ir.ui.view">

<field name="name">my.view.products.tree.inherit</field>

<field name="model">product.template</field>

<field name="inherit_id" ref="product.product_template_tree_view"/>

<field name="arch" type="xml">

<!-- Before the field 'name' i add the 'default_code' field, or any field from my product form-->

<field name="name" position="before">

<field name="default_code"/>

</field>

</field>

</record>

Go to top menu/apps on line then go to left menu update apps list, delete the filter in the search box app and put my and search, then install the module myproductviewtreelist

Avatar
Discard
Best Answer

In your __openerp__.py file you should add your custom view:

'data': [
'yourmodule_view.xml'
]

Regards.

Avatar
Discard
Best Answer

In your module you have declared new class custom_products...

and in view you are calling odl class product.product...

rename your module class to :

class product_product (osv.osv):
..... 

 

Avatar
Discard
Related Posts Replies Views Activity
3
Mar 15
5557
1
Mar 22
1968
0
Aug 21
2405
1
May 16
2682
2
Mar 15
5789