[IMP] stock: simplify stock.picking states
Remove 'partially_available'. This particular state is now also represented by the 'assigned' state.
This commit is contained in:
@@ -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()
|
||||
|
||||
@@ -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)]
|
||||
|
||||
|
||||
@@ -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'
|
||||
|
||||
@@ -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
|
||||
-
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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({
|
||||
|
||||
@@ -201,9 +201,8 @@
|
||||
<form string="Transfer">
|
||||
<header>
|
||||
<field name="is_locked" invisible="1"/>
|
||||
<button name="action_confirm" states="draft" string="Mark as Todo" type="object" class="oe_highlight" groups="base.group_user"/>
|
||||
<button name="action_confirm" attrs="{'invisible': ['|', ('state', '!=', 'draft'), ('id', '=', False)]}" string="Mark as Todo" type="object" class="oe_highlight" groups="base.group_user"/>
|
||||
<button name="action_assign" attrs="{'invisible': ['|', ('state', 'not in', ('confirmed', 'waiting')), ('is_locked', '=', False)]}" string="Check Availability" type="object" class="oe_highlight" groups="base.group_user"/>
|
||||
<button name="action_assign" attrs="{'invisible': ['|', ('state', '!=', 'partially_available'), ('is_locked', '=', False)]}" string="Recheck Availability" type="object" groups="base.group_user"/>
|
||||
<button name="force_assign" attrs="{'invisible': ['|', ('state', 'not in', ('confirmed', 'waiting', 'partially_available')), ('is_locked', '=', False)]}" string="Force Availability" type="object" groups="stock.group_stock_manager"/>
|
||||
<button name="button_validate" attrs="{'invisible': ['|', ('state', 'not in', ('draft', 'partially_available', 'assigned')), ('is_locked', '=', False)]}" string="Validate" groups="stock.group_stock_user" type="object" class="oe_highlight"/>
|
||||
<button name="do_print_picking" string="Print" groups="stock.group_stock_user" type="object" attrs="{'invisible': ['|', ('state', 'not in', ('assigned', 'partially_available')), ('is_locked', '=', False)]}"/>
|
||||
|
||||
Reference in New Issue
Block a user