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

Add Custom Field To Products

By
MoayadRayyan
on 11/16/14, 6:45 AM 1,575 views

Greetings,

Can someone help me with this issue .

since 2days am tring to create custome module that will add custome field to the products .

i faced many problems like , the field added to the view but not visible (i can check it on manage view ) .

so any one can help me out and give me a custome module that will add field under 'quantity on hand ' which accessed throw product > invetory tab

any one can do this favor for me please .

Regards

 

 

@MoayadRayyan, Please post back with details regarding what type of field you want to add. I have created a quick module for adding product images in a tab on product.template for Odoo 8.0 here: https://github.com/lukebranch/website_multi-image You may want to take a look at it's structure as a reference to help you achieve what you want to do.

Luke Branch
on 11/17/14, 6:32 AM
0
Eric
On 11/17/14, 5:25 PM

Make sure that your custom module is in the addons folder if it isn't already.  Then make sure you have the __init__.py, __openerp__.py, and any other python or xml view files in your module folder.  Ex:

product_custom_module_folder:

    > __init__.py

    > __openerp__.py

    > product_custom.py

    > product_custom_view.xml

 

In the __init__.py file write the name of all the python files in your module without the .py file extenstion like this:

import product_custom

 

In the product_custom.py file you can include your custom field by inheriting from the products model like this:

class product_product(orm.Model):

    _inherit = 'product.product'

    _columns = { 

            'custom_field_1': fields.integer( 'Name of custom field'),

            'custom_field_2': fields.char('Name of other custom field'),

    }

 

In the __openerp__.py file make sure to include the following:

{
    'name': 'Custom Product Module',
    'version': '1.0',
    'summary': 'Custom Product Module. . . ',
    'description':'''
        Custom Sale module to add additional fields without modifying the original Sale module
    ''',
    'category': 'Custom Products',
    'author': 'Your Name',
    'website': 'http://www.yourwebsite.com',
    'depends': ['product'],
    'data': [
      'product_custom_view.xml',
    ],
    'installable': True,
    'auto_install': False,
}

Note:  You will only need to add the xml file if you plan on creating new or modifying other views

Once you have all of those files in place, then go to Settings > Update Modules List and click the Update button

Then click on Installed Modules, and clear the "Installed" search filter in the upper right corner and type in the name of the new module.  When you see it, you can click Install and then your custom field will be added to the products table.  Hope this helps

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

2 follower(s)

Stats

Asked: 11/16/14, 6:45 AM
Seen: 1575 times
Last updated: 3/16/15, 8:10 AM