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

Unable to cancel orders placed prior to module installation #130

Closed MatthieuCardin closed 9 months ago

MatthieuCardin commented 9 months ago

Hi!

The cancel action from the admin do not work with any order passed before the module installation. Error shown is:

Source model with the order ID "12345" does not exist

The reason is that past orders do not have any row in the order_sources table. The exception is thrown from:

src/Model/SourcesRepository.php::getByOrderId(string $orderId)

Workaround: In our case, we manually added a row in the order_sources table for orders we wanted to cancel.

Fix I think you should fix this part of the code:

src/Observer/CancelOrderItemObserver.php : $this->executeSourceDeductionForItems->executeSourceDeductionForItems($orderItem, $itemsToCancel, true);

when the order is not found, do nothing instead of throwing the exception.

Best regards, Matthieu Cardin Valtech

convenient commented 9 months ago

Hey @MatthieuCardin

Fixed in https://github.com/AmpersandHQ/magento2-disable-stock-reservation/releases/tag/1.3.0

See https://github.com/AmpersandHQ/magento2-disable-stock-reservation/pull/124

MatthieuCardin commented 9 months ago

@convenient Nice! Thank you