Currently commerce_purchase_order table makes it difficult to build new features on top of the module, because there is not a clear relationship between transaction objects and PO record.
For example, View displaying list of transactions cannot display PO numbers, which especially impacts VBO.
Another example: Deleting a transaction, when there are more than one PO transaction per order, makes it pretty complicated to delete the right record in `commerce_purchase_order` table.
Proposed solution: Introduce transaction_id field into commerce_purchase_order database and make it a primary key.
Comments
Comment #2
bbujisic commentedAttached patch adds the extra
transaction_idfield to the schema and makes it a primary key, while keeping theorder_id-po_numberpair unique.hook_update_n()populates transaction_id's whenever PO number could be determined from existing "commerce_purchase_order" transactions. Other (orphaned?) purchase order records are being deleted in order to make sure notransaction_id == NULLnonsense breaksdb_add_primary_key()function.It is a relatively large change. A review would be appreciated.
Comment #3
bbujisic commentedFixed in a commit related to #2878829: Delete 'commerce_purchase_order' record when appropriate transaction was deleted