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

Module: Inventory

Entity: stock.scrap

Compute Method: _compute_scrap_location_id

View 19.0
Inputs Method Outputs
  • company_id
  • company_id.ids
  • company_id.id
- groups = self.env['stock.location']._read_group(
-             [('company_id', 'in', self.company_id.ids), ('usage', '=', 'inventory')], ['company_id'], ['id:min'])
- locations_per_company = {
-             company.id: stock_warehouse_id
-             for company, stock_warehouse_id in groups
-         }
- for scrap in self:
-             if scrap.company_id:
-                 scrap.scrap_location_id = locations_per_company.get(scrap.company_id.id, False)
  • scrap_location_id

Back to entity