Odoo has special support for monetary values related to a currency. Let's see how to use it in a model.
Adding a monetary field to a Model
Getting ready
We will reuse the my_module addon module from Chapter 4, Creating Odoo Addon Modules.
How to do it...
The monetary field needs a complementary currency field to store the currency for the amounts.
The my_module already has a models/library_book.py defining a basic model. We will edit this to add the required fields:
- Add the field to store the currency that is to be used:
class LibraryBook(models.Model): # ...