How to do it...

To extract grouped results, we will add the _get_average_cost method, which will use the read_group() method to fetch the data in a group:

    @api.model
def _get_average_cost(self):
grouped_result = self.read_group(
[('cost_price', "!=", False)], # Domain
['category_id', 'cost_price:avg'], # Fields to access
['category_id'] # group_by
)
return grouped_result

To test this implementation, you need to add a button in the user interface that triggers this method.

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

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