How to related PO with SO item

For handling pre-order/backorder, we have a requirement to relate an sales order item with the related purchase order. In Apache OFBiz, we used a field correspondingPoId available with OrderItem entity.

How can we achieve it in Moqui framework?

1 Like

I think that you’re looking for OrderItem.fromAssetIdAsset.acquireOrderId, Asset.acquireOrderItemSeqId, Asset.acquireShippingIdOrderHeader.orderId.

Hope that helps!

Also might want to checkout Asset.availableToPromiseTotal.

The path described here is correct with Asset.acquireOrderId and Asset.acquireOrderItemSeqId, but going through Asset is a bit funky because you’d have to create the record and plan the shipments and such way in advance. There is an Asset status meant for Asset records that have not yet been received, and some for those that have already been shipped but we want to track them because they have serial numbers and such.

On a side note, the path from OrderItem to the Assets that were actually shipped for it (for sales orders, outgoing shipments), is actually through the AssetIssuance entity. The OrderItem.fromAssetId is only rarely used and only when a particular Asset record is known in advance (for example a product with a serial number that the customer pulled from the shelf, for that old in-person shopping thing; I’m sure there are better examples, included whatever this was added for that I can’t remember now :slight_smile: ).

For a better solution to this problem we could use a join entity going from and to the OrderItem entity, ie like OrderItemAssoc similar to other *Assoc entities. An alternative, probably not what we’d want for flexibility, would be to add 2 fields to OrderItem so the sales item could point to the PO item.

This is based on the assumption that you are doing something similar to drop-shipping where you place a purchase order with a supplier for each sales order a customer sends you (shipment sent from supplier directly to the customer), or even if shipped through you similar in the flow for purchasing.

1 Like