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

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

By
Jeff Beidler
on 8/22/14, 4:06 PM 699 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?

1
Lucio
On 8/22/14, 4:55 PM

Hi,

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': [
        'product',
    ],
    '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.

Lucio
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

gunnar
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

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: 8/22/14, 4:06 PM
Seen: 699 times
Last updated: 3/16/15, 8:10 AM