How to add custom field on any object in OpenERP - Odoo



How to add custom field on any object in OpenERP (Odoo) without doing any hardcode!!

Say for example we need a field “Weight” on Vehicle.

Step 1: Activate Developers Mode.

a) To do that click on user name at the right upper corner of your screen and select About OpenERP (Odoo) option.

Add custom field in OpenERP

Activate Developer Mode

 
b) You will get window as shown in image below. Click on the link Activate the developer mode.

Add custom field in OpenERP


Activate Developer Mode

c) We will get a debug view From where we can edit all views of selected object.

Add custom field in OpenERP

Debug View


Step 2: Identify your object

To do that just hover your mouse on any of the field. It will show you some information like field name, object, field type etc.

Add custom field in OpenERP

Field information

As we know now that our object name is 'fleet.vehicle' and we have to add a new field to this object say for example 'weight', type of this field is integer. Let's edit our object. Here one thing is to notice that these changes are for the existing database only, it will not reflect in other database.

a) Go to the menu Settings → Techniacl → Database Structure → Models and search for fleet.vehicle

Add custom field in OpenERP

Object Search

b) Open that object and click on edit, drag the mouse to reach bottom of the page and click on Add an item link.

Add custom field in OpenERP

Object View


c) Add all detail like field name, label, type then click on 'Save & Close' button and finally click on Save button which is in Red color.

Add custom field in OpenERP

Add new field

As a field x_weight is added to our object fleet.vehicle we will now edit different views of vehicle to see the changes.

Step 3: Edit View(Form, tree)

a) Before editing excising views lets observe our current view.
Open Vehicle form view and see there is not any field with label “Weight” on it.

Add custom field in OpenERP

Vehicle's form view without any Change


b) Select the option Edit Form View from Debug View window.

Add custom field in OpenERP


Edit Form View

c) You will get a window as below. Insert the new field to appropriate position, and click on save button.

Add custom field in OpenERP

Insert new field

d) Close the window and reload the page. Here we can notice that a new field is on vehicle form view. Same way we can edit search, tree view.

Add custom field in OpenERP


Vehicle's form view with a new weight field 



By: Purnendu Singh
Thanks,

Mayur Maheshwari