Adding a monetary field to a model
To work with monetary values and currencies in a model, we can use Odoo to provide special support for working with monetary values and currencies in its models, through the use of specific field types and features. Odoo’s special support for monetary values and currencies simplifies the handling of financial data, ensuring accuracy, consistency, and compliance with currency-related requirements.
Getting ready
We will use the same my_hostel
add-on module from the previous recipe.
How to do it…
We need to add a currency field along with a monetary field to store the currency for the amounts.
We will add models/hostel_room.py
, to add the necessary fields:
- Create the field to store the currency for the amounts:
class HostelRoom(models.Model):     _name = "hostel.room"     …#     currency_id = fields.Many2one('res.currency', string...