IDEMPIERE-1144 Generating shipments from existing orders fails if product has mandatory attribute set / thanks to Tony Snook (tspc) for the initial patch

This commit is contained in:
Carlos Ruiz 2014-03-12 21:45:02 -05:00
parent 367ca9794e
commit f269768f71
7 changed files with 100 additions and 15 deletions

View File

@ -27,7 +27,7 @@ WHERE (o.DocStatus = 'CO' AND o.IsDelivered='N') -- Status must be CO - not CL
-- Not confirmed shipment
AND NOT EXISTS (SELECT * FROM M_InOutLine iol
INNER JOIN M_InOut io ON (iol.M_InOut_ID=io.M_InOut_ID)
WHERE iol.C_OrderLine_ID=l.C_OrderLine_ID AND io.DocStatus IN ('IP','WC'))
WHERE iol.C_OrderLine_ID=l.C_OrderLine_ID AND io.DocStatus IN ('DR','IN','IP','WC'))
--
GROUP BY o.AD_Client_ID, o.AD_Org_ID, o.C_BPartner_ID, o.C_Order_ID,
o.DocumentNo, o.DateOrdered, o.C_DocType_ID,

View File

@ -27,7 +27,7 @@ WHERE (o.DocStatus = 'CO' AND o.IsDelivered='N') -- Status must be CO - not CL
-- Not confirmed shipment
AND NOT EXISTS (SELECT * FROM M_InOutLine iol
INNER JOIN M_InOut io ON (iol.M_InOut_ID=io.M_InOut_ID)
WHERE iol.C_OrderLine_ID=l.C_OrderLine_ID AND io.DocStatus IN ('IP','WC'))
WHERE iol.C_OrderLine_ID=l.C_OrderLine_ID AND io.DocStatus IN ('DR','IN','IP','WC'))
--
GROUP BY o.AD_Client_ID, o.AD_Org_ID, o.C_BPartner_ID, o.C_Order_ID,
o.DocumentNo, o.DateOrdered, o.C_DocType_ID,

View File

@ -0,0 +1,43 @@
-- IDEMPIERE-1144 Generating shipments from existing orders fails if product has mandatory attribute set
CREATE OR REPLACE VIEW M_INOUT_CANDIDATE_V
(AD_CLIENT_ID, AD_ORG_ID, C_BPARTNER_ID, C_ORDER_ID, DOCUMENTNO,
DATEORDERED, C_DOCTYPE_ID, POREFERENCE, DESCRIPTION, SALESREP_ID,
M_WAREHOUSE_ID, TOTALLINES)
AS
SELECT
o.AD_Client_ID, o.AD_Org_ID, o.C_BPartner_ID, o.C_Order_ID,
o.DocumentNo, o.DateOrdered, o.C_DocType_ID,
o.POReference, o.Description, o.SalesRep_ID,
l.M_Warehouse_ID,
SUM((l.QtyOrdered-l.QtyDelivered)*l.PriceActual) AS TotalLines
FROM C_Order o
INNER JOIN C_OrderLine l ON (o.C_Order_ID=l.C_Order_ID)
WHERE (o.DocStatus = 'CO' AND o.IsDelivered='N') -- Status must be CO - not CL/RE
-- not Offers and open Walkin-Receipts
AND o.C_DocType_ID IN (SELECT C_DocType_ID FROM C_DocType
WHERE DocBaseType='SOO' AND DocSubTypeSO NOT IN ('ON','OB','WR'))
-- Delivery Rule - not manual
AND o.DeliveryRule<>'M'
AND (l.M_Product_ID IS NULL OR EXISTS
(SELECT * FROM M_Product p
WHERE l.M_Product_ID=p.M_Product_ID AND p.IsExcludeAutoDelivery='N'))
-- we need to ship
AND l.QtyOrdered <> l.QtyDelivered
AND o.IsDropShip='N'
AND (l.M_Product_ID IS NOT NULL OR l.C_Charge_ID IS NOT NULL)
-- Not confirmed shipment
AND NOT EXISTS (SELECT * FROM M_InOutLine iol
INNER JOIN M_InOut io ON (iol.M_InOut_ID=io.M_InOut_ID)
WHERE iol.C_OrderLine_ID=l.C_OrderLine_ID AND io.DocStatus IN ('DR','IN','IP','WC'))
--
GROUP BY o.AD_Client_ID, o.AD_Org_ID, o.C_BPartner_ID, o.C_Order_ID,
o.DocumentNo, o.DateOrdered, o.C_DocType_ID,
o.POReference, o.Description, o.SalesRep_ID, l.M_Warehouse_ID
;
SELECT register_migration_script('201403122133_IDEMPIERE-1144.sql') FROM dual
;

View File

@ -0,0 +1,43 @@
-- IDEMPIERE-1144 Generating shipments from existing orders fails if product has mandatory attribute set
CREATE OR REPLACE VIEW M_INOUT_CANDIDATE_V
(AD_CLIENT_ID, AD_ORG_ID, C_BPARTNER_ID, C_ORDER_ID, DOCUMENTNO,
DATEORDERED, C_DOCTYPE_ID, POREFERENCE, DESCRIPTION, SALESREP_ID,
M_WAREHOUSE_ID, TOTALLINES)
AS
SELECT
o.AD_Client_ID, o.AD_Org_ID, o.C_BPartner_ID, o.C_Order_ID,
o.DocumentNo, o.DateOrdered, o.C_DocType_ID,
o.POReference, o.Description, o.SalesRep_ID,
l.M_Warehouse_ID,
SUM((l.QtyOrdered-l.QtyDelivered)*l.PriceActual) AS TotalLines
FROM C_Order o
INNER JOIN C_OrderLine l ON (o.C_Order_ID=l.C_Order_ID)
WHERE (o.DocStatus = 'CO' AND o.IsDelivered='N') -- Status must be CO - not CL/RE
-- not Offers and open Walkin-Receipts
AND o.C_DocType_ID IN (SELECT C_DocType_ID FROM C_DocType
WHERE DocBaseType='SOO' AND DocSubTypeSO NOT IN ('ON','OB','WR'))
-- Delivery Rule - not manual
AND o.DeliveryRule<>'M'
AND (l.M_Product_ID IS NULL OR EXISTS
(SELECT * FROM M_Product p
WHERE l.M_Product_ID=p.M_Product_ID AND p.IsExcludeAutoDelivery='N'))
-- we need to ship
AND l.QtyOrdered <> l.QtyDelivered
AND o.IsDropShip='N'
AND (l.M_Product_ID IS NOT NULL OR l.C_Charge_ID IS NOT NULL)
-- Not confirmed shipment
AND NOT EXISTS (SELECT * FROM M_InOutLine iol
INNER JOIN M_InOut io ON (iol.M_InOut_ID=io.M_InOut_ID)
WHERE iol.C_OrderLine_ID=l.C_OrderLine_ID AND io.DocStatus IN ('DR','IN','IP','WC'))
--
GROUP BY o.AD_Client_ID, o.AD_Org_ID, o.C_BPartner_ID, o.C_Order_ID,
o.DocumentNo, o.DateOrdered, o.C_DocType_ID,
o.POReference, o.Description, o.SalesRep_ID, l.M_Warehouse_ID
;
SELECT register_migration_script('201403122133_IDEMPIERE-1144.sql') FROM dual
;

View File

@ -57,7 +57,7 @@ public class InOutGenerate extends SvrProcess
/** Include Orders w. unconfirmed Shipments */
private boolean p_IsUnconfirmedInOut = false;
/** DocAction */
private String p_docAction = DocAction.ACTION_Complete;
private String p_docAction = DocAction.ACTION_None;
/** Consolidate */
private boolean p_ConsolidateDocument = true;
/** Shipment Date */
@ -123,9 +123,6 @@ public class InOutGenerate extends SvrProcess
m_movementDate = new Timestamp(System.currentTimeMillis());
} else
m_movementDate = p_DateShipped;
// DocAction check
if (!DocAction.ACTION_Complete.equals(p_docAction))
p_docAction = DocAction.ACTION_Prepare;
}
} // prepare
@ -244,7 +241,7 @@ public class InOutGenerate extends SvrProcess
if (!p_IsUnconfirmedInOut)
where.append(" AND NOT EXISTS (SELECT * FROM M_InOutLine iol")
.append(" INNER JOIN M_InOut io ON (iol.M_InOut_ID=io.M_InOut_ID) ")
.append("WHERE iol.C_OrderLine_ID=C_OrderLine.C_OrderLine_ID AND io.DocStatus IN ('IP','WC'))");
.append("WHERE iol.C_OrderLine_ID=C_OrderLine.C_OrderLine_ID AND io.DocStatus IN ('DR','IN','IP','WC'))");
// Deadlock Prevention - Order by M_Product_ID
MOrderLine[] lines = order.getLines (where.toString(), "C_BPartner_Location_ID, M_Product_ID");
for (int i = 0; i < lines.length; i++)
@ -269,7 +266,7 @@ public class InOutGenerate extends SvrProcess
BigDecimal unconfirmedShippedQty = Env.ZERO;
if (p_IsUnconfirmedInOut && product != null && toDeliver.signum() != 0)
{
String where2 = "EXISTS (SELECT * FROM M_InOut io WHERE io.M_InOut_ID=M_InOutLine.M_InOut_ID AND io.DocStatus IN ('IP','WC'))";
String where2 = "EXISTS (SELECT * FROM M_InOut io WHERE io.M_InOut_ID=M_InOutLine.M_InOut_ID AND io.DocStatus IN ('DR','IN','IP','WC'))";
MInOutLine[] iols = MInOutLine.getOfOrderLine(getCtx(),
line.getC_OrderLine_ID(), where2, null);
for (int j = 0; j < iols.length; j++)
@ -573,12 +570,14 @@ public class InOutGenerate extends SvrProcess
private void completeShipment()
{
if (m_shipment != null)
{
if (!DocAction.ACTION_None.equals(p_docAction))
{
// Fails if there is a confirmation
if (!m_shipment.processIt(p_docAction)) {
log.warning("Failed: " + m_shipment);
throw new IllegalStateException("Shipment Process Failed: " + m_shipment + " - " + m_shipment.getProcessMsg());
}
}
m_shipment.saveEx();
String message = Msg.parseTranslation(getCtx(), "@ShipmentProcessed@ " + m_shipment.getDocumentNo());

View File

@ -143,7 +143,7 @@ public class VInOutGen extends InOutGen implements FormPanel, ActionListener, Ve
// Document Action Prepared/ Completed
MLookup docActionL = MLookupFactory.get(Env.getCtx(), m_WindowNo, 4324 /* M_InOut.DocStatus */,
DisplayType.List, Env.getLanguage(Env.getCtx()), "DocAction", 135 /* _Document Action */,
false, "AD_Ref_List.Value IN ('CO','PR')");
false, "AD_Ref_List.Value IN ('CO','PR','--')");
docAction = new VLookup("DocAction", true, false, true,docActionL);
docAction.addVetoableChangeListener(this);
// C_Order.C_BPartner_ID

View File

@ -138,7 +138,7 @@ public class WInOutGen extends InOutGen implements IFormController, EventListene
lDocAction.setText(Msg.translate(Env.getCtx(), "DocAction"));
MLookup docActionL = MLookupFactory.get(Env.getCtx(), form.getWindowNo(), 4324 /* M_InOut.DocAction */,
DisplayType.List, Env.getLanguage(Env.getCtx()), "DocAction", 135 /* _Document Action */,
false, "AD_Ref_List.Value IN ('CO','PR')");
false, "AD_Ref_List.Value IN ('CO','PR','--')");
docAction = new WTableDirEditor("DocAction", true, false, true,docActionL);
docAction.setValue(DocAction.ACTION_Complete);
// docAction.addValueChangeListener(this); // IDEMPIERE-768