issue #22669: Some changes to support creating supply orders on Sales Orders

Mostly fixes to event handling problems. Also fix to P/O status handling when a P/O is being destroyed.