[IMP] stock: don't auto. assign backorder

Before this commit, when a backorder is created, it was automatically
reserved. It is no more the case. Now user have to reserve it manually.

The reason is, when a user doesn't delivery all expected quantities, it
could be because there is no enough quantity in stock, or the user
doesn't want to delivery all. In these cases, it doesn't make sense to
reserved it directly.

task-2181611
This commit is contained in:
svs-odoo
2020-05-25 11:08:04 +00:00
parent 6501713d9a
commit 6b15eab7e1
2 changed files with 8 additions and 6 deletions
-1
View File
@@ -1029,7 +1029,6 @@ class Picking(models.Model):
moves_to_backorder.write({'picking_id': backorder_picking.id})
moves_to_backorder.mapped('package_level_id').write({'picking_id':backorder_picking.id})
moves_to_backorder.mapped('move_line_ids').write({'picking_id': backorder_picking.id})
backorder_picking.action_assign()
backorders |= backorder_picking
return backorders
+8 -5
View File
@@ -117,10 +117,10 @@ class TestPickShip(TestStockCommon):
# Now partially transfer the ship
picking_client.move_lines[0].move_line_ids[0].qty_done = 5
picking_client._action_done() # no new in order to create backorder
picking_client._action_done() # no new in order to create backorder
backorder = self.env['stock.picking'].search([('backorder_id', '=', picking_client.id)])
self.assertEqual(backorder.state, 'assigned', 'Backorder should be started')
self.assertEqual(backorder.state, 'waiting', 'Backorder should be waiting for reservation')
def test_mto_moves_transfer(self):
"""
@@ -291,8 +291,8 @@ class TestPickShip(TestStockCommon):
# create a backorder
picking_pick._action_done()
picking_pick_backorder = self.env['stock.picking'].search([('backorder_id', '=', picking_pick.id)])
self.assertEqual(picking_pick_backorder.state, 'assigned')
self.assertEqual(picking_pick_backorder.move_line_ids.product_qty, 5.0)
self.assertEqual(picking_pick_backorder.state, 'confirmed')
self.assertEqual(picking_pick_backorder.move_lines.product_qty, 5.0)
self.assertEqual(picking_client.state, 'assigned')
@@ -771,10 +771,13 @@ class TestSinglePicking(TestStockCommon):
delivery_order.move_lines[0].move_line_ids[0].qty_done = 1
delivery_order._action_done()
self.assertNotEqual(delivery_order.date_done, False)
self.assertEqual(self.env['stock.quant']._get_available_quantity(self.productA, pack_location), 0.0)
self.assertEqual(self.env['stock.quant']._get_available_quantity(self.productA, pack_location), 1.0)
backorder = self.env['stock.picking'].search([('backorder_id', '=', delivery_order.id)])
self.assertEqual(backorder.state, 'confirmed')
backorder.action_assign()
self.assertEqual(backorder.state, 'assigned')
self.assertEqual(self.env['stock.quant']._get_available_quantity(self.productA, pack_location), 0.0)
def test_backorder_2(self):
""" Check the good behavior of creating a backorder for a partially available stock move.