summaryrefslogtreecommitdiff
path: root/addons
diff options
context:
space:
mode:
authorSimon Lejeune <sle@openerp.com>2017-12-28 15:55:49 +0100
committerSimon Lejeune <sle@openerp.com>2017-12-29 15:56:30 +0100
commit652f8746d6d1cc16bed1d388a4341f717c93dbcb (patch)
tree2ec2024b356e4091df3543c92595274ac2ec3a2c /addons
parent88afd055cfc96f6505eec7547419ad96e37ab28d (diff)
[FIX] stock: state of DO for an MTO product
When confirming a quotation for an MTO product, the state of the delivery order goes from draft to waiting another operation to waiting while it should stays in waiting another operation. If procurement_jit is enabled, confirming a sale order line will unreserve and rereserve the pickings associated (see `action_launch_procurement_rule` override). Unreserving a picking will always set its state to "confirmed", which is wrong if it should be in "waiting another operation". Not writing on state (which is a computed field) and let the depends call _compute_state fixes the issue. The unreserve/rereserve thing is probably useless and is a remain of the previous stock implementation where it was not possible to complete the reservation of a move without wiping all its current reservation. Another commit will improve this part of the code. opw-801588
Diffstat (limited to 'addons')
-rw-r--r--addons/stock/models/stock_picking.py6
-rw-r--r--addons/stock/tests/test_move2.py17
2 files changed, 19 insertions, 4 deletions
diff --git a/addons/stock/models/stock_picking.py b/addons/stock/models/stock_picking.py
index 66197571b12..9c24a04c0f4 100644
--- a/addons/stock/models/stock_picking.py
+++ b/addons/stock/models/stock_picking.py
@@ -666,10 +666,8 @@ class Picking(models.Model):
@api.multi
def do_unreserve(self):
- for move in self:
- for move_line in move.move_lines:
- move_line._do_unreserve()
- self.write({'state': 'confirmed'})
+ for picking in self:
+ picking.move_lines._do_unreserve()
@api.multi
def button_validate(self):
diff --git a/addons/stock/tests/test_move2.py b/addons/stock/tests/test_move2.py
index f3bb72268c2..a3a6b0ae46b 100644
--- a/addons/stock/tests/test_move2.py
+++ b/addons/stock/tests/test_move2.py
@@ -648,6 +648,23 @@ class TestPickShip(TestStockCommon):
self.assertEqual(picking_client.move_lines.state, 'confirmed', 'The move should be confirmed since all the origin moves are processed.')
self.assertEqual(picking_client.state, 'confirmed', 'The picking should be confirmed since all the moves are confirmed.')
+ def test_unreserve(self):
+ picking_pick, picking_client = self.create_pick_ship()
+
+ self.assertEqual(picking_pick.state, 'confirmed')
+ picking_pick.do_unreserve()
+ self.assertEqual(picking_pick.state, 'confirmed')
+ location = self.env['stock.location'].browse(self.stock_location)
+ self.env['stock.quant']._update_available_quantity(self.productA, location, 10.0)
+ picking_pick.action_assign()
+ self.assertEqual(picking_pick.state, 'assigned')
+ picking_pick.do_unreserve()
+ self.assertEqual(picking_pick.state, 'confirmed')
+
+ self.assertEqual(picking_client.state, 'waiting')
+ picking_client.do_unreserve()
+ self.assertEqual(picking_client.state, 'waiting')
+
class TestSinglePicking(TestStockCommon):
def test_backorder_1(self):