Sylius/Sylius — pull request #986 by winzou (2014-02-05 09:59:00+00:00)
Title: [POC] Attach InventoryUnit to OrderItem instead of Order

We still have a synchronization issue between order items and inventory units. Promotion with free product breaks it, because it's attached to an event that `InventoryHandler` doesn't listen.

I suggest we attach inventory units to order item instead of the order itself. We will then be able to create inventory units at the moment we attach items to order (not implemented yet). With this solution, we ensure inventory units are perfectly synchronized with items: created when we attach item to order, and deleted when we delete item (there is an orphanRemoval true on the relation).

In this way, we do not need the `InventoryHandler::processInventoryUnits` method anymore. The handler service will only take care of states & cie.

What do you think?

The only drawback is that we kind of hardcode the link, by creating via `new InventoryUnit` inside Order or OrderItem. But this is something anyone can override and get back to the old and buggy behavior.