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

Module: DDMRP

Entity: mrp.bom

Compute Method: _compute_context_location

Inputs Method Outputs
  • company_id
warehouse_model = self.env["stock.warehouse"]
for rec in self:
            if self.env.context.get("location_id", None):
                rec.context_location_id = self.env.context.get("location_id")
            elif self.env.context.get("warehouse", None):
                warehouse_id = self.env.context.get("warehouse")
                rec.context_location_id = warehouse_model.browse(
                    warehouse_id
                ).lot_stock_id.id
            else:
                company_id = rec.company_id or self.env.company
                warehouse_id = warehouse_model.search(
                    [("company_id", "=", company_id.id)], limit=1
                )
                rec.context_location_id = warehouse_id.lot_stock_id.id

Back to entity