AmpersandHQ / magento2-disable-stock-reservation

This module disables the inventory reservation logic introduced as part of MSI in Magento 2.3.3
GNU Lesser General Public License v3.0
211 stars 60 forks source link

Prevent the need for source selection when shipping via Admin #127

Closed convenient closed 7 months ago

convenient commented 9 months ago

Attempt to resolve https://github.com/AmpersandHQ/magento2-disable-stock-reservation/issues/121

In that issue it is reported that if the products stock is all the way to 0 you cannot ship the order as you cannot select a source.

Conceptually, the source is already selected when the order is created so this entire screen of source selection before creating a shipment does not seem necessary to me. This screen is injected in two places

Ship button URL replacement

https://github.com/magento/inventory/blob/062205f54be17ad70aa341f63fd5037b61a4c7d8/InventoryShippingAdminUi/Block/Adminhtml/Order/View/ShipButton.php#L63-L77

This block is injected to swap out the url so that you go straight to source selection when you hit "ship". this is solved by removing the block.

Observer to force redirect when starting a new shipment

There is an observer on controller_action_predispatch_adminhtml_order_shipment_new which will force a redirect to the source selection screen

https://github.com/magento/inventory/blob/062205f54be17ad70aa341f63fd5037b61a4c7d8/InventoryShippingAdminUi/Observer/NewShipmentLoadBefore.php#L86-L92

Disabling this observer allows you to go straight to the order ship page to create a shipment.

Before

https://github.com/AmpersandHQ/magento2-disable-stock-reservation/assets/600190/480f0121-1bb0-4234-827f-9abc62126315

Hitting "ship" takes you to the source selection screen, to either

  1. Make a choice that doesnt really even make sense or do anything (because the inventory has already been deducated on placement)
  2. Be stuck, if the quantity is at 0

After

https://github.com/AmpersandHQ/magento2-disable-stock-reservation/assets/600190/f8f48153-46f8-499f-b594-e4c1be317abe

Hitting "ship" takes you to the shipment screen

Checklist