|
|
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
|
|