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

Module: Product State

Entity: product.state

Compute Method: _compute_products_count

Inputs Method Outputs
  • id
data = self.env["product.template"].read_group(
            [("product_state_id", "in", self.ids)],
            ["product_state_id"],
            ["product_state_id"],
        )
mapped_data = {
            record["product_state_id"][0]: record["product_state_id_count"]
            for record in data
        }
for state in self:
            state.products_count = mapped_data.get(state.id, 0)

Back to entity