Adding an OWL field to the form view
Up to this point, we have learned about all the basics of OWL. Now we will move on to more advanced aspects and create a field widget that can be used in the form view, just like the field widget recipe from the previous chapter. In this recipe, we will create a color picker widget that will save integer values based on the color selected.
To make the example more informative, we will use some advanced concepts of OWL. We will use multiple components, custom events, external QWeb templates, and more.
Getting ready
For this recipe, we will continue using the my_library
module from the previous recipe.
How to do it...
Perform the following steps to add a new OWL field component to choose the colors on the form view:
- Add a color integer field to the
library.book
model as follows:color = fields.Integer()
- Add the same field to the form view, with a widget attribute as well:
<field name="color" widget="int_color...