How to do it...

The monetary field needs a complementary currency field to store the currency for the amounts.

my_library already has models/library_book.py, which defines a basic model. We will edit this to add the required fields:

  1. Add the field to store the currency that is to be used:
class LibraryBook(models.Model): 
    # ... 
    currency_id = fields.Many2one( 
        'res.currency', string='Currency') 
  1. Add the monetary field to store the amount:
class LibraryBook(models.Model): 
    # ... 
    retail_price = fields.Monetary( 
        'Retail Price', 
        # optional: currency_field='currency_id', 
        ) 

Now, upgrade the add-on module, and the new fields should be available in the model. They won't be visible in views until they are added to them, but we can confirm their addition by inspecting the model fields in Settings | Technical | Database Structure | Models. After adding them into the form view, it will look as follows:

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset