File upload within the Acumatica system is done through the UploadFileMaintenance
graph. The data record that is referenced is UploadFile
You can accomplish your goal of "run a method when a file is attached to a document in Acumatica" a variety of ways.
You can add an event handler to UploadFileMaintenance via an extension as seen below
public class UploadFileMaintenanceExtension : PXGraphExtension<UploadFileMaintenance>
{
public virtual void __(Events.RowInserting<UploadFile> e)
{
}
public virtual void __(Events.RowInserted<UploadFile> e)
{
}
}
Actions can then be determined based on the files origination information ect.

Similarly you can add an event for file saving specific to PO with the following
public class POOrderEntryExtension : PXGraphExtension<POOrderEntry>
{
public override void Initialize()
{
PXGraph.InstanceCreated.AddHandler<UploadFileMaintenance>((graph) =>
graph.RowInserting.AddHandler<UploadFile>((sender, e) =>
{
//Your code here
}));
base.Initialize();
}
}