Odoo Mindscape. Understand Odoo faster. Explore modules, fields, dependencies and version differences in one place instead of digging through the source code.

Module: Lunch

Entity: lunch.product.category

Compute Method: _compute_product_count

Inputs Method Outputs
  • id
product_data = self.env['lunch.product']._read_group([('category_id', 'in', self.ids)], ['category_id'], ['__count'])
data = {category.id: count for category, count in product_data}
for category in self:
            category.product_count = data.get(category.id, 0)

Back to entity