From 4afaed61407b53acd4a08c2a70d3c3debde04fab Mon Sep 17 00:00:00 2001 From: Carlos Ruiz Date: Wed, 15 Jul 2020 05:05:49 +0200 Subject: [PATCH] IDEMPIERE-3062 Unable to complete MR with qty >1 with Attribute Set of Always Mandatory (#144) --- .../src/org/compiere/model/MInOut.java | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/org.adempiere.base/src/org/compiere/model/MInOut.java b/org.adempiere.base/src/org/compiere/model/MInOut.java index be0113f9db..31fc959547 100644 --- a/org.adempiere.base/src/org/compiere/model/MInOut.java +++ b/org.adempiere.base/src/org/compiere/model/MInOut.java @@ -1203,9 +1203,21 @@ public class MInOut extends X_M_InOut implements DocAction if (product != null && product.isASIMandatory(isSOTrx())) { if (product.getAttributeSet() != null && !product.getAttributeSet().excludeTableEntry(MInOutLine.Table_ID, isSOTrx())) { - m_processMsg = "@M_AttributeSet_ID@ @IsMandatory@ (@Line@ #" + lines[i].getLine() + - ", @M_Product_ID@=" + product.getValue() + ")"; - return DocAction.STATUS_Invalid; + BigDecimal qtyDiff = line.getMovementQty(); + // verify if the ASIs are captured on lineMA + MInOutLineMA mas[] = MInOutLineMA.get(getCtx(), + line.getM_InOut_ID(), get_TrxName()); + BigDecimal qtyma = Env.ZERO; + for (MInOutLineMA ma : mas) { + if (! ma.isAutoGenerated()) { + qtyma = qtyma.add(ma.getMovementQty()); + } + } + if (qtyma.subtract(qtyDiff).signum() != 0) { + m_processMsg = "@M_AttributeSet_ID@ @IsMandatory@ (@Line@ #" + lines[i].getLine() + + ", @M_Product_ID@=" + product.getValue() + ")"; + return DocAction.STATUS_Invalid; + } } } }