Building a Form View in Odoo

A form view is how a single record is seen and edited. How a developer builds one.

A model defines a kind of record; a form view is how a single such record is seen and edited. This piece is about building a form view in Odoo.

What a form view is

A form view is the view that presents a single record for viewing and editing: the form a user sees when they look at, or edit, one record, with the record's fields laid out. Where the model defines what a record is, the form view defines how a record is presented to the people who work with it. For a kind of record to be genuinely usable, it needs a form view, since the form view is how a user genuinely sees and edits a record.

Building a form view

A form view, in Odoo, is defined in XML, in a module's views. The developer builds the form view by defining, in XML, how the record's fields are laid out on the form: which fields appear, how they are arranged, the structure of the form. Building the form view is, in essence, writing that XML definition of the record's presentation. The form view is built for a particular model, presenting that model's records.

Building a good form view

Building a form view well is about making the form a genuinely good way to see and work with the record. A good form view presents the record's fields clearly, arranged sensibly, so a user can genuinely understand the record and edit it without difficulty. The fields should be laid out in a way that makes sense, grouped and structured sensibly, so the form is clear rather than a confusing jumble. Building a good form view means thinking about how the record is genuinely worked with and laying the form out to suit that, so the form genuinely helps the people who use it.

The form view and the model

An honest point. A form view presents a model's records, so building a form view goes together with the model it is for. The form view shows the model's fields, and a good form view presents them well; it builds on a model that is itself well defined, with the right fields. Building a form view is, in a sense, the presentation layer on top of the model: the model defines the record, the form view presents it. A developer building functionality for a new kind of record builds the model and then the form view to present it, the two together making the kind of record genuinely usable.

Build it the Odoo way

Building a form view, like all Odoo development, should be done the Odoo way: form views have an established way they are defined in Odoo, the XML structure, the conventions, and a form view built that way works properly within the framework and is maintainable. A developer building a form view should do it within Odoo's conventions, working with the framework. Following the established way is part of building the form view well.

The takeaway

Building a form view in Odoo defines how a single record is presented for viewing and editing, done in XML, in a module's views, laying out the record's fields on the form. A form view is what makes a kind of record genuinely usable, since it is how a user sees and edits a record. Build a good form view by presenting the fields clearly and arranging them sensibly, so the form genuinely helps the people who use it. The form view builds on a well-defined model, and it should be built the Odoo way. For how we approach Odoo, see our ERP practice.

All posts

Got a Topic Worth Posting?

Suggest a Topic

If a question keeps coming up in your operations, it might be worth its own post.