Odoo Help


Add custom Field in Products (V7)

Aeneas Winterhalter
on 7/10/13, 12:37 PM 10,709 views

Im tring to add a custom Field to the Products, but i dont get it... When im right, i easily go to "database structure" and "fields" and klick "add". But then i stuck at the standart field on the right side, when im right i have to choose "product.product", set a name and Save the Bad boy. Is this correct so far?

Then the next step would be go to "user interface" then "view" and add my field. But what do i have to write at the object field?

Down at Architecture ist: <tree string="My view"> <field name="name"/> </tree>

and when i trie to safe the whole thing i get an error, that the xml code is wrong.

So how can i make it?



| 5 4 7
Baarn, Netherlands
On 7/10/13, 1:42 PM

r way of adding fields to a model is working, but limits you in what you can do with that field. If you need to do calculations based on that field, you cannot do it without modifying python code.

Also when you have done a lot of modifications like this, and you need to setup another database, you have to do it all over again, manually (this will give errors, because you forget one, or setup one field a bit different than on the other server).

The preferred method is to create a new module, and install that module to get the new field(s) and method(s).

Example of module:

my_module (folder with following files)
- __init__.py
- __openeerp__.py
- my_module_code.py
- my_module_code_view.xml


#name of python file with code
import my_module_code


    'name': 'Name of module,
    'version': '0.1',
    'category': 'Others',
    'complexity': "normal",
    'description': """ Some description of your module """
    'author': ['Your name'],
    'website': 'my.website.com',
    'depends': [
        "product" #name of module which is needed to be installed
    'init_xml': [
        #place here the XML with initial data
    'update_xml': [
    'demo_xml': [],
    'test': [],
    'installable': True,
    'auto_install': False,
    'application': False,
    'images': [],
    'js': [],


from openerp.osv import fields, osv

class product_product(osv.osv):
Modified product.product
    _inherit = "product.product"

    _columns = {
        'my_new_field': fields.char('LABEL new Field', select=True,
            help='HELP text when hovering over the label in openERP'),

def my_method(self, cr, uid, ids):
    """Description of my_method """
    #do your actions here

def existing_method(self, cr, uid, ... ):
    """ Override existing method, use same parameters as original """
    # do some action
    res = super(product_product, self_).existing_method(cr, uid, ...)
    # do some more actions
    return res #might be modified


<?xml version="1.0" encoding="utf-8"?>
<!-- Adding the fields from product.product to the screen -->
        <record id="product_normal_form_view" model="ir.ui.view">
            <field name="name">base.product.defaults.product.form</field>
            <field name="model">product.product</field>
            <field name="inherit_id" ref="product.product_normal_form_view"/>
            <field name="arch" type="xml">
                <field name='default_code' position='before'>
                    <field name="my_new_field"/>

Okay, i see the problem and i dont think that i can handle it alone. Were a small Business in Germany and we really need this kind of Plugin. If you have time to support us (of course paid) it would be great if you could send me a message to w.aeneas (AT) me . com. Thanks!

Aeneas Winterhalter
on 7/10/13, 2:05 PM

@patrick, how did you insert formatted code in your answer?

Leonardo Donelli
on 9/10/14, 4:36 AM

Is there an option to add different fields depending on the product category? For example a RAM will have a "memory" field. But a keyboard will have a "color" field.

on 9/29/14, 5:28 AM
kostas gobakis
On 9/5/13, 8:26 PM

Hi Do i need some special permition in order OpenERP 7 to see the custom module ( i use Windows 7 )?

After Installation somewhere in the server addon path, you must refresh the list of modules, for US Language is "Settings/Modules/Update". Then you can search your custom module in "Installed modules".

Michel Hugues
on 9/10/14, 6:57 AM
Ryno Meyer
On 9/10/14, 4:28 AM

@patric. Great comment on adding an extra field module. I am however struggling to do the same with pos.order. The problem is with the view.xml, where I am not sure which model and id to reference.

My code is as follows:

<?xml version="1.0" encoding="utf-8"?>
<!-- Adding the fields from product.product to the screen -->
        <record id="product_normal_form_view" model="ir.ui.view">
            <field name="name">base.pos.defaults.order.form</field>
            <field name="model">pos.order</field>
            <field name="inherit_id" ref="pos.order.action_pos_pos_form"/>
            <field name="arch" type="xml">
                <field name='default_code' position='before'>
                    <field name="credit_card" string='Credit Card'/>

I am aware my problem lies with the record id=? and field name='inherit_id" ref=?. Would you be able to assist please. I attempted looking at point_of_sale_view.xml and tried to use the id I pressume was correct, to no avail. How do you determine the correct id? and what is the syntax?
Thank you in advance.

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 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

0 follower(s)


Asked: 7/10/13, 12:37 PM
Seen: 10709 times
Last updated: 3/16/15, 8:10 AM