Adding a float field with configurable precision
When using float fields, we may want to let the end user configure the decimal precision that will be used. In this recipe, we will add a hostel_rating field to the hostel model, with user-configurable decimal precision.
Getting ready
We will continue using the my_hostel add-on module from the previous recipe.
How to do it...
Perform the following steps to apply dynamic decimal precision to the model’s hostel_rating field:
- Create a data folder and add a
data.xmlfile. Inside this file, add the following record for the decimal precision model. This will add a new configuration.<record forcecreate="True" id="decimal_point" model="decimal.precision"> <field name="name">Rating Value</field> <field name="digits">3</field> </record>
- Activate Developer Mode from the link in the Settings menu (refer to the Activating the Odoo developer...