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

Compute Method: _compute_location_id

Inputs Method Outputs
ir_default_get = self.env['ir.default'].sudo()._get
default_customer_location_id = ir_default_get('res.partner', 'property_stock_customer')
default_supplier_location_id = ir_default_get('res.partner', 'property_stock_supplier')
for picking in self:
            if picking.state in ('cancel', 'done') or picking.return_id:
                continue
            picking = picking.with_company(picking.company_id)
            if picking.picking_type_id:
                location_src = picking.picking_type_id.default_location_src_id
                if location_src.usage == 'supplier' and picking.partner_id:
                    supplier_location = picking.partner_id.property_stock_supplier
                    if supplier_location and supplier_location.id != default_supplier_location_id:
                        location_src = supplier_location
                location_dest = picking.picking_type_id.default_location_dest_id
                if location_dest.usage == 'customer' and picking.partner_id:
                    customer_location = picking.partner_id.property_stock_customer
                    if customer_location and customer_location.id != default_customer_location_id:
                        location_dest = customer_location
                picking.location_id = location_src.id
                picking.location_dest_id = location_dest.id

Back to entity