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

Module: Products & Pricelists

Entity: product.attribute

Compute Method: _compute_number_related_products

Inputs Method Outputs
  • id
res = {
            attribute.id: count
            for attribute, count in self.env['product.template.attribute.line']._read_group(
                domain=[('attribute_id', 'in', self.ids), ('product_tmpl_id.active', '=', True)],
                groupby=['attribute_id'],
                aggregates=['__count'],
            )
        }
for pa in self:
            pa.number_related_products = res.get(pa.id, 0)

Back to entity