summaryrefslogtreecommitdiff
path: root/addons
diff options
context:
space:
mode:
authorSimon Lejeune <sle@openerp.com>2017-10-30 16:15:01 +0100
committerSimon Lejeune <sle@openerp.com>2017-10-31 17:13:27 +0100
commit3b91780bc02023be4fc8455e89da9b8a83aee8e6 (patch)
tree0cc2f16f0ca67edff803d091bfafc0de9841bdaa /addons
parentf4866ab7f9c613df3860d66641901fbd024c74e5 (diff)
[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.
Diffstat (limited to 'addons')
-rw-r--r--addons/stock/models/stock_move.py7
-rw-r--r--addons/stock/test/packing.yml5
-rw-r--r--addons/stock/test/packingneg.yml3
3 files changed, 14 insertions, 1 deletions
diff --git a/addons/stock/models/stock_move.py b/addons/stock/models/stock_move.py
index 0ad0284b60b..4c8e5e81116 100644
--- a/addons/stock/models/stock_move.py
+++ b/addons/stock/models/stock_move.py
@@ -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()
diff --git a/addons/stock/test/packing.yml b/addons/stock/test/packing.yml
index b84e38e5985..1ae21fe611f 100644
--- a/addons/stock/test/packing.yml
+++ b/addons/stock/test/packing.yml
@@ -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" \ No newline at end of file
+ assert product.qty_available == 0, "Quantity available should be 0 too"
diff --git a/addons/stock/test/packingneg.yml b/addons/stock/test/packingneg.yml
index ca3305dad0b..4c4ca1d1cbc 100644
--- a/addons/stock/test/packingneg.yml
+++ b/addons/stock/test/packingneg.yml
@@ -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
-