Hello @bwhite49, Based on my debugging, it seems like the issue is caused by StatusID check happening in AMProdItem_RowDeleting event which leads to the error. Overriding the event to avoid the validation for your custom statuses as below would fix this error:
protected virtual void AMProdItem_RowDeleting(PXCache cache, PXRowDeletingEventArgs e, PXRowDeleting basemethod)
{
var amProdItem = (AMProdItem)e.Row;
if (amProdItem == null)
{
return;
}
if (amProdItem.Hold.GetValueOrDefault())
{
throw new PXSetPropertyException(Messages.GetLocal(Messages.ProdStatusDeleteInvalid, Messages.Hold));
}
if (!(amProdItem.StatusID.EqualsWithTrim("Q") || amProdItem.StatusID.EqualsWithTrim("W") || amProdItem.StatusID.EqualsWithTrim("E")))
{
if (!amProdItem.StatusID.EqualsWithTrim(ProductionOrderStatus.Planned))
{
var label = ProductionOrderStatus.GetStatusDescription(amProdItem.StatusID.TrimIfNotNullEmpty().ToUpper());
throw new PXSetPropertyException(Messages.GetLocal(Messages.ProdStatusDeleteInvalid, label));
}
}
if (!Base.IsContractBasedAPI && !Base.IsImport && !Base.IsImportFromExcel)
{
var relatedOrders = Base.relatedProdOrders.Select().RowCast<AMProdItemRelated>().ToList();
if (relatedOrders.Any())
{
string[] relatedOrderNumbers = relatedOrders.Select(s => $"{s.OrderType} - {s.ProdOrdID}").ToArray();
if (Base.relatedProdOrders.Ask(
Messages.DeleteProductionOrderTitle,
Messages.GetLocal(Messages.LinkedOrderAllocationDeleteConfirmation, string.Join(", ", relatedOrderNumbers)), MessageButtons.YesNo) != WebDialogResult.Yes)
{
e.Cancel = true;
return;
}
}
}
if (Base.ContainsSOReference)
{
AMConfigurationResults confRow = Base.ItemConfiguration.SelectWindowed(0, 1, new object[] { amProdItem });
if (!Base.IsImport)
{
if (Base.ProdMaintRecords.Ask(Messages.ConfirmDeleteTitle, Messages.ConfirmSOLinkedOrderDelete, MessageButtons.YesNo) != WebDialogResult.Yes)
{
e.Cancel = true;
}
}
if (confRow != null && e.Cancel == false)
{
//We don't want to delete the Configuration if it's still linked with a SOLine
PXParentAttribute.SetLeaveChildren<AMConfigurationResults.prodOrderNbr>(Base.Caches[typeof(AMConfigurationResults)], null, true);
//We want to remove the linked with the defunct production order.
confRow.ProdOrderType = null;
confRow.ProdOrderNbr = null;
this.Base.ItemConfiguration.Update(confRow);
}
}
if (ProductionTransactionHelper.ProductionOrderHasUnreleasedTransactions(this.Base, amProdItem, out var unreleasedMsg))
{
throw new PXException(unreleasedMsg);
}
}
Hope this helps!