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.
Odoo has many widgets in the UI for different functionalities, such as a status bar, checkboxes, and radio buttons. which makes the operations in Odoo simpler and run with ease. For example, we used widget='image'
to display a binary field as an image. To demonstrate how to create your own widget, we’ll write one widget that lets the user choose an integer field, but we will display it differently. Instead of an input box, we will display a color picker so that we can select a color number. Here, each number will be mapped to a color.
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...