[REF] stock: result package consistency

Make sure that the all move lines having the same result package have
the some destination location. This should not happen with the
previous commit.

Adapt the tests accordingly, their behaviour was wrong.
This commit is contained in:
Simon Lejeune
2017-10-31 17:13:27 +01:00
parent f4866ab7f9
commit 3b91780bc0
3 changed files with 14 additions and 1 deletions
+7
View File
@@ -1025,6 +1025,13 @@ class StockMove(models.Model):
# If you were already putting stock.move.lots on the next one in the work order, transfer those to the new move
move.move_line_ids.filtered(lambda x: x.qty_done == 0.0).write({'move_id': new_move})
move.move_line_ids._action_done()
# Check the consistency of the result packages; there should be an unique location across
# the contained quants.
for result_package in moves_todo\
.mapped('move_line_ids.result_package_id')\
.filtered(lambda p: p.quant_ids and len(p.quant_ids) > 1):
if len(result_package.quant_ids.mapped('location_id')) > 1:
raise UserError(_('You should not put the contents of a package in different locations.'))
picking = self and self[0].picking_id or False
moves_todo.write({'state': 'done', 'date': fields.Datetime.now()})
moves_todo.mapped('move_dest_ids')._action_assign()
+4 -1
View File
@@ -118,10 +118,13 @@
for rec in self.move_line_ids:
if rec.package_id.name == 'Pallet 1':
rec.qty_done = 120
rec.result_package_id = False
if rec.package_id.name == 'Pallet 2':
rec.qty_done = 20
rec.result_package_id = False
if rec.package_id.name == 'Pallet 3':
rec.qty_done = 10
rec.result_package_id = False
-
Process this picking
-
@@ -167,4 +170,4 @@
total_qty += rec.quantity
product = self.env["product.product"].browse(ref('product1'))
assert total_qty == 0, "Total quantity in stock should be 0 as the backorder took everything out of stock"
assert product.qty_available == 0, "Quantity available should be 0 too"
assert product.qty_available == 0, "Quantity available should be 0 too"
+3
View File
@@ -96,12 +96,15 @@
for rec in self.move_line_ids:
if rec.package_id.name == 'Palneg 1':
rec.qty_done = rec.product_qty
rec.result_package_id = False
elif rec.package_id.name == 'Palneg 2' and rec.lot_id.name == 'Lot neg' :
rec.write({
'qty_done': 140,
'result_package_id': False,
})
elif rec.package_id.name == 'Palneg 3':
rec.qty_done = 10
rec.result_package_id = False
-
Process this picking
-