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

Module: Repairs

Entity: stock.lot

Compute Method: _compute_repair_line_ids

Inputs Method Outputs
repair_orders = defaultdict(lambda: self.env['repair.order'])
repair_moves = self.env['stock.move'].search([
            ('repair_id', '!=', False),
            ('repair_line_type', '!=', False),
            ('move_line_ids.lot_id', 'in', self.ids),
            ('state', '=', 'done')])
for repair_line in repair_moves:
            for rl_id in repair_line.lot_ids.ids:
                repair_orders[rl_id] |= repair_line.repair_id
for lot in self:
            lot.repair_line_ids = repair_orders[lot.id]
            lot.repair_part_count = len(lot.repair_line_ids)

Back to entity