[FIX] stock: compute locations for picking partners

Steps to reproduce:
- Enable multi-step reception
- Create a reception in WH/Input
- Open an internal picking further down the chain
- Change its contact

Issue:
The location_id and location_dest_id is getting reset to Operation
type's default locations, which will raise a warning because the
location/dest don't match the ones from the moves anymore.

It was decided to only allow the automatic compute of locations for
draft pickings. Which means :
- Compute will trigger normally when manually creating a picking
- Picking type is readonly outside of draft anyway, so don't change
anything for this change
- Changing locations of a non-draft picking is a risky operation, as
they won't match the moves. So better leave it as a manual change.

closes odoo/odoo#140055

Signed-off-by: William Henrotin (whe) <whe@odoo.com>
This commit is contained in:
clesgow
2023-10-27 14:22:13 +00:00
parent 074a453611
commit 1085afd637
+2
View File
@@ -743,6 +743,8 @@ class Picking(models.Model):
@api.depends('picking_type_id', 'partner_id')
def _compute_location_id(self):
for picking in self:
if picking.state != 'draft':
continue
picking = picking.with_company(picking.company_id)
if picking.picking_type_id:
if picking.picking_type_id.default_location_src_id: