In the previous recipes, we saw how we can search and fetch data from the database. But sometimes, you want results by aggregating records, such as the average cost for last month's sales order. In this case, you can use the read_group() method to get the aggregate result.
Fetching data in groups with read_group()
Getting ready
In this recipe, we will use the my_library add-on module from Chapter 4, Creating Odoo Add-On Modules.
Modify the library.book model, as shown in the following model definition:
class LibraryBook(models.Model):
_name = 'library.book'
name = fields.Char('Title', required=True)
date_release = fields.Date('Release Date')
pages = fields.Integer('Number...