Reputation: 804
When attempting to create a Sales Order via an API call, if the Vendor marked as Default for any item on the order has status Inactive an error is returned with the message: "PX.Data.PXException: The vendor status is 'Inactive'"
However, when creating the Sales Order through the standard Screen there is no issue with ordering items with Inactive Default Vendors.
We want to keep the Vendors marked as Inactive but need to create the Sales Orders for the items like the Screen allows. How can this be done?
Upvotes: 0
Views: 308
Reputation: 804
From Brendan's comment I went with modifying the PXRestrictor attribute of the SOLine.VendorID to allow Inactive status as well:
public class SOLineExt : PXCacheExtension<PX.Objects.SO.SOLine> {
[PXMergeAttributes(Method = MergeMethod.Merge)]
[PXRestrictor(typeof(Where<Vendor.status, IsNull,
Or<Vendor.status, Equal<BAccount.status.active>,
Or<Vendor.status, Equal<BAccount.status.inactive>,
Or<Vendor.status, Equal<BAccount.status.oneTime>>>>>), PX.Objects.AP.Messages.VendorIsInStatus, typeof(Vendor.status))]
public virtual Int32? VendorID { get; set; }
}
Upvotes: 0
Reputation: 8278
I'm assuming the error is coming from SOLine.VendorID from Brendan comment.
Here are the steps to debug that problem and fix it using FieldVerifying event.
Add SOLine.VendorID field on SalesOrder screen:
Reproduce the error in SalesOrder using the field you added:
Check trace error, it indicates the error is coming from a PXRestrictor attribute:
Check VendorID field, it has a PXRestrictor and the VendorIsInStatus error message you receive:
PXRestrictor attribute validation can be cancelled using the FieldVerifying event, add that handler to SalesOrder for SOLine.VendorID:
public class SOOrderEntry_Extension:PXGraphExtension<SOOrderEntry>
{
protected void SOLine_VendorID_FieldVerifying(PXCache sender, PXFieldVerifyingEventArgs e)
{
e.Cancel = true;
}
}
Test SalesOrder again, if it works you can remove the VendorID/VendorName you added to the grid to debug:
Upvotes: 2