Odoo Help


which is the standard approach to add new fields to an odoo delivered model ?

T Star
on 10/15/15, 9:26 AM 1,157 views

Hi Team,

I am new to Odoo, could you please help me understand which is the standard approach to add new fields to an odoo delivered model.

Say, if I need to create two new additional fields (profession and hobby) to existing CRM_LEAD model.

I understand that the basic approach is to add those new fields to the _inherit object of CRM_LEAD model

class AddNewfield(models.Model):

_inherit = "crm.lead"

Profession = fields.Char('Profession', size=20, required=True)

Hobby = fields.Char('Hobby', size=20)

But I had come across article stating that its not advisable to add new fields to odoo delivered model, as this might impact future upgrade.

Then, should I have to build a new model adding these two fields and a many2one field to the parent table.

class AddNewModel(models.Model):

_name = "crm.AddNewModel"

Profession = fields.Char('Profession', size=20, required=True)

Hobby = fields.Char('Hobby', size=20)

lead_id = fields.Many2one('crm.lead', required=True)

Let me know if which is the right approach.

As well how will I be able to display the new fields from model crm_AddNewModel in the Leads standard form view.

1st approach is right one, but create a new module for do those changes don't do in "CRM" or any standard module.

on 10/18/15, 2:11 PM
Andrea Dalseno
On 10/18/15, 10:23 AM

Hi, if you use the _name attribute in your class you are inheriting the model creating a new (different) one. If you omit the _name, you will inherit from the model extending it. In the first case you will inherit the view definition, but not its design that must be recreated from scratch (or so its seems; I had o do that and have a question open on this matter), in the second case you will operate directly in the standard model/view.

To add a field follow the link given by Temur and read the docs. In the case of extension, i.e. without _name, you will simply need to create your extended view (an XML file, with the correct reference) and add the fields in the desired position with <field name="filedX" position ="before/after..."> or using an Xpath expression (if the name is not unique). You can find a good, simple and readable example in the Geo Localization module (that adds some fields to res.partner). To know the name of the fields you can activate the developer mode and the name of the fields will appear on the screen when you pass the mouse over a field.

This code will add my custom field (titolo) in res.partner view after the field "website" adding a label to the new field and a placeholder (a suggestion) for the field:

<!-- Custom Field -->

<label for="titolo" string="Titolo"/>

<xpath expr="//field[@name='website']" position="after">

<field name="titolo" placeholder="SPETTABILE STUDIO DENTISTICO" />



Ray Carnes

--Ray Carnes--
| 9 7 9
Keyport, United States
--Ray Carnes--

Senior ERP Analyst

OpenERP 6.1, 7.0; Odoo 8.0, 9.0, 10.0 and 11.0.

Completed Odoo Functional and Technical Training.

Functional Areas:

  • CRM/Sales

  • Inventory

  • Manufacturing

  • Accounting

  • Purchasing

Major Skills:

  • Business Process Reengineering

  • Efficiency Consulting

  • User Needs and GAP Analysis;

  • Functional and Technical Design;

  • Prototyping and Proof of Concepts;

  • Requirements Specifications;

  • Agile Implementation;

  • Data Migration;

  • Configuration & Customization (UI and code);

  • Integration - Odoo and non Odoo Applications and Services;

  • Training and Knowledge Transfer;

  • Go Live Support;

  • Helpdesk;

  • Version Upgrades and Migration.

  • Accounting Expert.

I have over 20 years of experience empowering and enabling users with enterprise information systems that make a real and measurable difference in their ability to proactively manage their businesses and organizations. 

I am a skilled Communicator and I only take the serious things seriously!

Ray Carnes
On 10/15/15, 1:30 PM

By stating:

_inherit = "crm.lead" 

You are in fact inheriting an Odoo model/class/object, and adding your fields to it.  This is the correct way.  You ARE creating your own model with this method. 

The CRM module from Odoo actually inherits and extends res_partner with new fields (although the the old API): 


I agree with Temur, check out the documentation for a more detailed explanation.




| 6 5 7
Tbilisi, Georgia
On 10/15/15, 9:58 AM

I think you can start with the Odoo documentation "Building a Module" at https://www.odoo.com/documentation/8.0/howtos/backend.html

Mateo Tibaquira
On 10/15/15, 11:28 AM

I think a relation is too much hassle, you better check the Delegation Inheritance to "embed" your model into "crm.lead" but keeping your data on another table transparently.

About the Views, you may enable the debug mode (/web?debug=1) and manage the current view (Bug icon at the top-right) to see what's the one you need to inherit from and add your fields there.

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

2 follower(s)


Asked: 10/15/15, 9:26 AM
Seen: 1157 times
Last updated: 10/18/15, 2:11 PM