diff --git a/addons/procurement_jit/sale.py b/addons/procurement_jit/sale.py index cf921fd88d8..ae6023e74b5 100644 --- a/addons/procurement_jit/sale.py +++ b/addons/procurement_jit/sale.py @@ -12,7 +12,7 @@ class SaleOrderLine(models.Model): res = super(SaleOrderLine, self)._action_launch_procurement_rule() orders = list(set(x.order_id for x in self)) for order in orders: - reassign = order.picking_ids.filtered(lambda x: x.state=='confirmed' or ((x.state in ['partially_available', 'waiting']) and not x.printed)) + reassign = order.picking_ids.filtered(lambda x: x.state=='confirmed' or (x.state in ['waiting', 'assigned'] and not x.printed)) if reassign: reassign.do_unreserve() reassign.action_assign() diff --git a/addons/stock/models/procurement.py b/addons/stock/models/procurement.py index 3894ad64fcd..988a87ada71 100644 --- a/addons/stock/models/procurement.py +++ b/addons/stock/models/procurement.py @@ -224,7 +224,7 @@ class ProcurementGroup(models.Model): ('location_dest_id', '=', values['location_id'].id), ('picking_type_id', '=', rule.picking_type_id.id), ('picking_id.printed', '=', False), - ('picking_id.state', 'in', ['draft', 'confirmed', 'waiting', 'partially_available', 'assigned']), + ('picking_id.state', 'in', ['draft', 'confirmed', 'waiting', 'assigned']), ('picking_id.backorder_id', '=', False), ('product_id', '=', values['product_id'].id)] diff --git a/addons/stock/models/stock_picking.py b/addons/stock/models/stock_picking.py index cd739b5bb42..e4fe78c4d6a 100644 --- a/addons/stock/models/stock_picking.py +++ b/addons/stock/models/stock_picking.py @@ -80,10 +80,10 @@ class PickingType(models.Model): domains = { 'count_picking_draft': [('state', '=', 'draft')], 'count_picking_waiting': [('state', 'in', ('confirmed', 'waiting'))], - 'count_picking_ready': [('state', 'in', ('assigned', 'partially_available'))], - 'count_picking': [('state', 'in', ('assigned', 'waiting', 'confirmed', 'partially_available'))], - 'count_picking_late': [('scheduled_date', '<', time.strftime(DEFAULT_SERVER_DATETIME_FORMAT)), ('state', 'in', ('assigned', 'waiting', 'confirmed', 'partially_available'))], - 'count_picking_backorders': [('backorder_id', '!=', False), ('state', 'in', ('confirmed', 'assigned', 'waiting', 'partially_available'))], + 'count_picking_ready': [('state', '=', 'assigned')], + 'count_picking': [('state', 'in', ('assigned', 'waiting', 'confirmed'))], + 'count_picking_late': [('scheduled_date', '<', time.strftime(DEFAULT_SERVER_DATETIME_FORMAT)), ('state', 'in', ('assigned', 'waiting', 'confirmed'))], + 'count_picking_backorders': [('backorder_id', '!=', False), ('state', 'in', ('confirmed', 'assigned', 'waiting'))], } for field in domains: data = self.env['stock.picking'].read_group(domains[field] + @@ -186,19 +186,20 @@ class Picking(models.Model): help="It specifies goods to be deliver partially or all at once") state = fields.Selection([ - ('draft', 'Draft'), ('cancel', 'Cancelled'), + ('draft', 'Draft'), ('waiting', 'Waiting Another Operation'), - ('confirmed', 'Waiting Availability'), - ('partially_available', 'Partially Available'), - ('assigned', 'Available'), ('done', 'Done')], string='Status', compute='_compute_state', + ('confirmed', 'Waiting'), + ('assigned', 'Ready'), + ('done', 'Done'), + ('cancel', 'Cancelled'), + ], string='Status', compute='_compute_state', copy=False, index=True, readonly=True, store=True, track_visibility='onchange', - help=" * Draft: not confirmed yet and will not be scheduled until confirmed\n" - " * Waiting Another Operation: waiting for another move to proceed before it becomes automatically available (e.g. in Make-To-Order flows)\n" - " * Waiting Availability: still waiting for the availability of products\n" - " * Partially Available: some products are available and reserved\n" - " * Ready to Transfer: products reserved, simply waiting for confirmation.\n" - " * Transferred: has been processed, can't be modified or cancelled anymore\n" - " * Cancelled: has been cancelled, can't be confirmed anymore") + help=" * Draft: not confirmed yet and will not be scheduled until confirmed.\n" + " * Waiting Another Operation: waiting for another move to proceed before it becomes automatically available (e.g. in Make-To-Order flows).\n" + " * Waiting: if it is not ready to be sent because the required products could not be reserved.\n" + " * Ready: products are reserved and ready to be sent. If the shipping policy is 'As soon as possible' this happens as soon as anything is reserved.\n" + " * Done: has been processed, can't be modified or cancelled anymore.\n" + " * Cancelled: has been cancelled, can't be confirmed anymore.") group_id = fields.Many2one( 'procurement.group', 'Procurement Group', @@ -287,14 +288,16 @@ class Picking(models.Model): @api.one def _compute_state(self): ''' State of a picking depends on the state of its related stock.move - - no moves: draft or assigned (launch_pack_operations) - - all moves canceled: cancel - - all moves done (including possible canceled): done - - All at once picking: least of confirmed / waiting / assigned - - Partial picking - - all moves assigned: assigned - - one of the move is assigned or partially available: partially available - - otherwise in waiting or confirmed state + - Draft: only used for "planned pickings" + - Waiting: if the picking is not ready to be sent so if + - (a) no quantity could be reserved at all or if + - (b) some quantities could be reserved and the shipping policy is "deliver all at once" + - Waiting another move: if the picking is waiting for another move + - Ready: if the picking is ready to be sent so if: + - (a) all quantities are reserved or if + - (b) some quantities could be reserved and the shipping policy is "as soon as possible" + - Done: if the picking is done. + - Cancelled: if the picking is cancelled ''' if not self.move_lines: self.state = 'draft' diff --git a/addons/stock/test/wiseoperator.yml b/addons/stock/test/wiseoperator.yml index 3814d744116..07dc1520dc4 100644 --- a/addons/stock/test/wiseoperator.yml +++ b/addons/stock/test/wiseoperator.yml @@ -142,10 +142,10 @@ ref('stock_location_stock'))]) assert len(records.ids) == 0, 'This should not have created a negative quant' - - Check the other delivery order has changed its state back to partially available + Check the other delivery order has changed its state back to ready - !python {model: stock.picking, id: delivery_order_wise2}: | - assert self.state == 'partially_available', "Delivery order 2 should be back in confirmed state" + assert self.state == 'assigned', "Delivery order 2 should be back in ready state" - Process the second picking - diff --git a/addons/stock/tests/test_move2.py b/addons/stock/tests/test_move2.py index cea81e5a663..0dc7904c561 100644 --- a/addons/stock/tests/test_move2.py +++ b/addons/stock/tests/test_move2.py @@ -203,11 +203,11 @@ class TestPickShip(TestStockCommon): self.assertEqual(picking_pick_backorder.state, 'assigned') self.assertEqual(picking_pick_backorder.move_line_ids.product_qty, 5.0) - self.assertEqual(picking_client.state, 'partially_available') + self.assertEqual(picking_client.state, 'assigned') # cancel the backorder picking_pick_backorder.action_cancel() - self.assertEqual(picking_client.state, 'partially_available') + self.assertEqual(picking_client.state, 'assigned') def test_edit_done_chained_move(self): """ Let’s say two moves are chained: the first is done and the second is assigned. @@ -230,7 +230,7 @@ class TestPickShip(TestStockCommon): picking_pick.move_lines[0].move_line_ids[0].qty_done = 5.0 self.assertEqual(picking_pick.state, 'done', 'The state of the pick should be done') - self.assertEqual(picking_client.state, 'partially_available', 'The state of the client should be partially available') + self.assertEqual(picking_client.state, 'assigned', 'The state of the client should be partially available') self.assertEqual(picking_pick.move_lines.quantity_done, 5.0, 'Wrong quantity_done for pick move') self.assertEqual(picking_client.move_lines.product_qty, 10.0, 'Wrong initial demand for client move') self.assertEqual(picking_client.move_lines.reserved_availability, 5.0, 'Wrong quantity already reserved for client move') @@ -574,7 +574,7 @@ class TestSinglePicking(TestStockCommon): # assign to partially available delivery_order.action_confirm() delivery_order.action_assign() - self.assertEqual(delivery_order.state, 'partially_available') + self.assertEqual(delivery_order.state, 'assigned') self.assertEqual(self.env['stock.quant']._get_available_quantity(self.productA, pack_location), 0.0) # valid with backorder creation @@ -741,7 +741,7 @@ class TestSinglePicking(TestStockCommon): delivery_order.action_confirm() delivery_order.action_assign() # Check State - self.assertEqual(delivery_order.state, 'partially_available') + self.assertEqual(delivery_order.state, 'assigned') self.assertEqual(move1.state, 'partially_available') # Check reserved quantity @@ -798,7 +798,7 @@ class TestSinglePicking(TestStockCommon): delivery_order.action_confirm() delivery_order.action_assign() # Check State - self.assertEqual(delivery_order.state, 'partially_available') + self.assertEqual(delivery_order.state, 'assigned') self.assertEqual(move1.state, 'partially_available') # Check reserved quantity @@ -858,7 +858,7 @@ class TestSinglePicking(TestStockCommon): delivery_order.action_confirm() delivery_order.action_assign() # Check State - self.assertEqual(delivery_order.state, 'partially_available') + self.assertEqual(delivery_order.state, 'assigned') self.assertEqual(move1.state, 'partially_available') # Check reserved quantity @@ -925,7 +925,7 @@ class TestSinglePicking(TestStockCommon): delivery_order.action_confirm() delivery_order.action_assign() # Check State - self.assertEqual(delivery_order.state, 'partially_available') + self.assertEqual(delivery_order.state, 'assigned') self.assertEqual(move1.state, 'partially_available') # Check reserved quantity diff --git a/addons/stock/tests/test_stock_flow.py b/addons/stock/tests/test_stock_flow.py index adf4fedabf2..6c3a1f45226 100644 --- a/addons/stock/tests/test_stock_flow.py +++ b/addons/stock/tests/test_stock_flow.py @@ -1559,7 +1559,7 @@ class TestStockFlow(TestStockCommon): to the state of its move lines and its move type. """ # move_type: direct == partial, one == all at once - # picking: confirmed == waiting availability, partially_available = partially available + # picking: confirmed == waiting availability # ----------------------------------------------------------- # "all at once" and "reserve" scenario @@ -1692,7 +1692,7 @@ class TestStockFlow(TestStockCommon): # validate this delivery order, it should be in partially available picking_out.action_assign() - self.assertEquals(picking_out.state, "partially_available") + self.assertEquals(picking_out.state, "assigned") # receive one product in stock inventory = self.env['stock.inventory'].create({ diff --git a/addons/stock/views/stock_picking_views.xml b/addons/stock/views/stock_picking_views.xml index 4b06be5582f..b486957fc30 100644 --- a/addons/stock/views/stock_picking_views.xml +++ b/addons/stock/views/stock_picking_views.xml @@ -201,9 +201,8 @@