Odoo Help


Is a .py file necessary, if I only want to add an existing field to a view in code?

Jeff Beidler
on 8/22/14, 4:06 PM 1,024 views

I'm working on my first OpenERP module.  (Woo hoo!)

All I really want to do is to add existing fields 'product_name' and 'product_code' (from product.supplierinfo) into View #233 (Product form view).  I'm talking about the Suppliers area that appears near the bottom of a product form view --> Procurements tab.  Developer mode tells me this area is the 'seller_ids' field from product.supplierinfo.

Since I'm not defining any new models or fields, do I still need to have a 'mymodule.py' file?  Or is a new .xml file for the view all I need?  If I still need a .py file, what do I put in it?




| 5 4 7
Buenos Aires, Argentina
Karma will give me a place in heaven!
On 8/22/14, 4:55 PM


You don't need a "mymodule.py" file, but you do need a __iniit__.py and __openerp__.py files.

The former can be empty, is just to indicate that your folder (where you are creating your .xml and so on) is in fact a module.
In the __openerp__.py file yo need to add the xml as data:

    'name': 'My Module',
    'version': '0.1',
    'author': 'You',
    'website': 'http://www.example.com',
    'depends': [
    'description' : """
                    Added fields to suppliers tree of product form view
    'data': ['your_view.xml',]

That's it!
Hope it helps, and welcome to OpenERP/Odoo!

Cool, thanks. Now I just have to figure out how to modify one view that is displayed inside another!

Jeff Beidler
on 8/22/14, 5:12 PM

Take a look at sale_stock/sale_stock_view.xml line88, you can do something like that. Something like: <xpath expr="//field[@name='seller_ids']/tree/field[@name='field_of_sellers_tree_view']" postion="after"> for editing the tree form for example.

on 8/22/14, 5:18 PM

Where do you find the .xml files? I'm looking in the OpenERP directory, and don't see them.

Jeff Beidler
on 8/22/14, 5:53 PM

@Jeff: go to /opt/openerp/openerp-server/addons or /opt/odoo/odoo-server/addons. Inside of each Module folder you can find the xml files for each Module

on 8/22/14, 8:06 PM

Hmm... neither /opt/openerp nor /opt/odoo exist. I installed on CentOS with a pre-made install script. Not sure where it put its files. Can't find any directory references other than for startup and .conf files.

Jeff Beidler
on 8/25/14, 11:47 AM

Found it! On my system, it is /usr/lib/python2.6/site-packages/openerp-7.0_20140804_231303-py2.6.egg/openerp/addons/sale_stock/sale_stock_view.xml Whew! That's a long one!

Jeff Beidler
on 8/25/14, 1:41 PM

About This Community

This platform 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.


Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now

Question tools

1 follower(s)


Asked: 8/22/14, 4:06 PM
Seen: 1024 times
Last updated: 3/16/15, 8:10 AM