Odoo 12 Development Essentials
上QQ阅读APP看书,第一时间看更新

Adding a field to a Model

To visit a Model's definition, with the developer mode enabled, in the Settings application go to the Technical | Database Structure | Models menu item.

Look up the Model having res.partner. The corresponding Model Description should be Contact. Click on it to open the form view, and you will see all the specific details about the partner model, including the field list:

Now, Edit the form and click on the Add a line button at the bottom of the Fields list. A pop-up window will be presented for new field creation.

Let's fill in the configuration:

  • Field Name: x_is_work_team
  • Field Label: Is Work Team?
  • Field Type: boolean

The Field Name must start with x_. This is mandatory for Models and Fields created directly through the user interface. Customizations made through add-on modules don't have this limitation.

That's it. Click save and close, and our new field should have been added to the Fields list. Chances are that this model has more than 80 fields, and so you might need to navigate to the next page of the Fields list to see it. To do so, use the right arrow in the upper-left corner of the Fields list.

Now, click on the upper-left save button to make this change permanent.