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

Module: Manufacturing

Entity: mrp.production

Compute Method: _compute_scrap_move_count

Inputs Method Outputs
  • id
scrapped_finished_data = self.env['stock.move']._read_group([('production_id', 'in', self.ids), ('is_scrap', '=', True)], ['production_id'], ['__count'])
scrapped_component_data = self.env['stock.move']._read_group([('raw_material_production_id', 'in', self.ids), ('is_scrap', '=', True)], ['raw_material_production_id'], ['__count'])
count_data = {production.id: count for production, count in scrapped_finished_data}
count_data.update({production.id: count_data.get(production.id, 0) + count for production, count in scrapped_component_data})
for production in self:
            production.scrap_count = count_data.get(production.id, 0)

Back to entity