There's more...

For numeric fields, you can add a sum attribute that causes this column to be summed up with the text you set in the attribute as a tooltip. Less common are the avg, min, and max attributes that display the average, minimum, and maximum, respectively. Note that these four only work on the records that are currently visible, so you might want to adjust the action's limit (covered earlier in the Adding a menu item and window action recipe) in order for the user to see all the records immediately.

A very interesting attribute for the tree element is editable. If you set this to top or bottom, the list behaves entirely differently. Without it, clicking on a row opens a form view for the row. With it, clicking on a row makes it editable inline, with the visible fields rendered as form fields. This is particularly useful in embedded list views, which are discussed later in the Defining embedded views recipe of this chapter. The choice of top or bottom relates to whether new lines will be added to the top or bottom of the list.

By default, records are ordered according to the _order property of the displayed model. The user can change the ordering by clicking on a column header, but you can also set a different initial order by setting the default_order property in the tree element. The syntax is the same as in _order.

Ordering is often a source of frustration for new developers. As Odoo lets PostgreSQL do the work here, you can only order by fields that PostgreSQL knows about and also only the fields that live in the same database table. So, if you want to order by a function or a related field, ensure that you set store=True. If you need to order by a field inherited from another model, declare a stored related field.

The create, edit, and delete attributes of the tree element work the same as for the form element we described earlier in the Adding content and widgets to a form view recipe of this chapter. They also determine the available controls if the editable attribute is set.

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

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