[FIX] stock: recompute on picking assign

- Create a kit (phantom BOM), composed of 2 different products A and B
- Create a SO, sell a random stockable product, confirm and validate the
  picking.
- Edit the SO, add the kit and save.

Two pickings are created, one for product A and one for product B.

Commit 8fe8ca9948 forces the recomputation of the stock moves, in order
to be able to find a newly created picking. This should actually be done
after each picking creation.

opw-725929
This commit is contained in:
Nicolas Martinelli
2017-04-05 08:12:10 +02:00
parent 910f12b88e
commit 300c678ade
+10 -8
View File
@@ -412,15 +412,8 @@ class StockMove(models.Model):
type (moves should already have them identical). Otherwise, create a new
picking to assign them to. """
Picking = self.env['stock.picking']
# If this method is called in batch by a write on a one2many and
# at some point had to create a picking, some next iterations could
# try to find back the created picking. As we look for it by searching
# on some computed fields, we have to force a recompute, else the
# record won't be found.
self.recompute()
for move in self:
recompute = False
picking = Picking.search([
('group_id', '=', move.group_id.id),
('location_id', '=', move.location_id.id),
@@ -429,8 +422,17 @@ class StockMove(models.Model):
('printed', '=', False),
('state', 'in', ['draft', 'confirmed', 'waiting', 'partially_available', 'assigned'])], limit=1)
if not picking:
recompute = True
picking = Picking.create(move._get_new_picking_values())
move.write({'picking_id': picking.id})
# If this method is called in batch by a write on a one2many and
# at some point had to create a picking, some next iterations could
# try to find back the created picking. As we look for it by searching
# on some computed fields, we have to force a recompute, else the
# record won't be found.
if recompute:
move.recompute()
return True
_picking_assign = assign_picking