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

Module: Delivery - Stock

Entity: stock.picking

Compute Method: _compute_packages

Inputs Method Outputs
  • move_line_ids
  • result_package_id
  • result_package_id.id
counts = dict(self.env['stock.move.line']._read_group(
           domain=[
              ('picking_id', 'in', self.ids),
              ('result_package_id', '!=', False)],
              groupby=['picking_id'],
              aggregates=['__count'],
        ))
self.fetch(['move_line_ids'])
self.move_line_ids.fetch(['result_package_id'])
for picking in self:
            packs = set()
            if counts.get(picking, 0):
                for move_line in picking.move_line_ids:
                    if move_line.result_package_id:
                        packs.add(move_line.result_package_id.id)
            picking.package_ids = list(packs)

Back to entity