Field

In order to actually show and manipulate data, your form should contain some field elements. They have one mandatory attribute called name, which refers to the field's name in the model. So earlier, we offer the user to edit the partner's name and categories. If we only want to show one of them, without the user being able to edit the field, we set the readonly attribute to 1 or True. This attribute may actually contain a small subset of Python code, so readonly="2>1" will make the field read-only too. The same applies to the invisible attribute, which you use to have the value read from the database, but not shown to the user. We'll see later in which situations we want to have that.

Take care not to put the same field twice on your form. Odoo is not designed to support this, and the result will be that all but one of those fields will behave as if they were empty; hidden fields especially can be a nasty source of trouble here.

You must have noticed the widget attribute on the categories field. It defines how the data in the field is supposed to be presented to the user. Every type of field has its standard widget, so you don't have to explicitly choose a widget. However, several types provide multiple ways of representation, in which case you might opt for something other than the default. As a complete list of available widgets will exceed the scope of this recipe, you'll have to resort to Odoo's source code to try them out and consult Chapter 15, Web Client Development, for details on how to make your own.