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: res.company

Compute Method: _compute_default_stock_location_id

Inputs Method Outputs
  • id
grouped_stock_locations = self.env['stock.warehouse']._read_group([('company_id', 'in', self.ids)], ['company_id'], ['lot_stock_id:array_agg'])
stock_locations_per_company = {company.id: lot_stock_ids[0] if lot_stock_ids else False for company, lot_stock_ids in grouped_stock_locations}
for company in self:
            company.default_stock_location_id = stock_locations_per_company.get(company.id)

Back to entity