Field

In order to actually show and manipulate data, your form view should contain some field elements. These have one mandatory attribute, called name, which refers to the field's name in the model. Earlier, we offered the user the ability to edit the partner's name and categories. If we only want to show one of these, 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. This also applies to the invisible attribute, for which you use to have a value that is read from the database, but not shown to the user. Later, we'll take a look at which situations this can be used in.

You must have noticed the widget attribute on the categories field. This defines how the data in the field is supposed to be presented to the user. Every type of field has a 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 would exceed the scope of this recipe, consult Odoo's source code to try them out. Take a look at Chapter 15, Web Client Development, for details on how to make your own.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset