Partial Approval Logic for Sales Order Items in ERPNext

In ERPNext, I have a Sales Order with two Sales Order Items. Each item has a unique ID.

When the Sales Order is in Draft status, I allow the customer to give feedback through an Issue form, where they can choose whether each item is “OK” (approved) or not.

Here’s the logic I want to implement:

  • If the customer approves one item and rejects the other, then:
    • The approved item’s status should be “Approved”.
    • The rejected item’s status should be “Rejected”.
    • The Sales Order’s overall status should change from Draft to Partial.
  • If both items are approved, the Sales Order should be Submitted.
  • If both items are rejected, the Sales Order should be Cancelled.

How can I implement this logic in ERPNext? Should I use custom fields, server scripts, or workflows? Has anyone done something similar?