diff --git a/org.adempiere.base/src/org/compiere/model/MAttributeSet.java b/org.adempiere.base/src/org/compiere/model/MAttributeSet.java index be02f0ae70..234badba8a 100644 --- a/org.adempiere.base/src/org/compiere/model/MAttributeSet.java +++ b/org.adempiere.base/src/org/compiere/model/MAttributeSet.java @@ -41,8 +41,7 @@ public class MAttributeSet extends X_M_AttributeSet /** * */ - private static final long serialVersionUID = -2703536167929259405L; - + private static final long serialVersionUID = -187568054160926817L; /** * Get MAttributeSet from Cache @@ -210,13 +209,40 @@ public class MAttributeSet extends X_M_AttributeSet } // isMandatoryShipping /** - * Exclude entry + * Exclude column entry * @param AD_Column_ID column * @param isSOTrx sales order * @return true if excluded */ public boolean excludeEntry (int AD_Column_ID, boolean isSOTrx) { + MColumn column = MColumn.get(getCtx(), AD_Column_ID); + return excludeTableEntry(column.getAD_Table_ID(), isSOTrx); + } // excludeEntry + + /** + * Exclude table entry + * @param AD_Table_ID column + * @param isSOTrx sales order + * @return true if excluded + */ + public boolean excludeTableEntry (int AD_Table_ID, boolean isSOTrx) + { + loadExcludes(); + // Find it + if (m_excludes != null && m_excludes.length > 0) + { + for (int i = 0; i < m_excludes.length; i++) + { + if (m_excludes[i].getAD_Table_ID() == AD_Table_ID + && m_excludes[i].isSOTrx() == isSOTrx) + return true; + } + } + return false; + } // excludeTableEntry + + private void loadExcludes() { if (m_excludes == null) { final String whereClause = X_M_AttributeSetExclude.COLUMNNAME_M_AttributeSet_ID+"=?"; @@ -227,19 +253,7 @@ public class MAttributeSet extends X_M_AttributeSet m_excludes = new X_M_AttributeSetExclude[list.size ()]; list.toArray (m_excludes); } - // Find it - if (m_excludes != null && m_excludes.length > 0) - { - MColumn column = MColumn.get(getCtx(), AD_Column_ID); - for (int i = 0; i < m_excludes.length; i++) - { - if (m_excludes[i].getAD_Table_ID() == column.getAD_Table_ID() - && m_excludes[i].isSOTrx() == isSOTrx) - return true; - } - } - return false; - } // excludeEntry + } /** * Exclude Lot creation diff --git a/org.adempiere.base/src/org/compiere/model/MInOut.java b/org.adempiere.base/src/org/compiere/model/MInOut.java index 3439a78d8e..2180842ddb 100644 --- a/org.adempiere.base/src/org/compiere/model/MInOut.java +++ b/org.adempiere.base/src/org/compiere/model/MInOut.java @@ -1186,9 +1186,11 @@ public class MInOut extends X_M_InOut implements DocAction continue; if (product != null && product.isASIMandatory(isSOTrx())) { - m_processMsg = "@M_AttributeSet_ID@ @IsMandatory@ (@Line@ #" + lines[i].getLine() + - ", @M_Product_ID@=" + product.getValue() + ")"; - return DocAction.STATUS_Invalid; + if (! 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; + } } } setVolume(Volume); diff --git a/org.adempiere.base/src/org/compiere/model/MInventoryLine.java b/org.adempiere.base/src/org/compiere/model/MInventoryLine.java index 34270120eb..5badb4c46a 100644 --- a/org.adempiere.base/src/org/compiere/model/MInventoryLine.java +++ b/org.adempiere.base/src/org/compiere/model/MInventoryLine.java @@ -260,7 +260,7 @@ public class MInventoryLine extends X_M_InventoryLine log.saveError("ParentComplete", Msg.translate(getCtx(), "M_InventoryLine")); return false; } - if (newRecord && m_isManualEntry) + if (m_isManualEntry) { // Product requires ASI if (getM_AttributeSetInstance_ID() == 0) @@ -268,11 +268,13 @@ public class MInventoryLine extends X_M_InventoryLine MProduct product = MProduct.get(getCtx(), getM_Product_ID()); if (product != null && product.isASIMandatory(isSOTrx())) { - log.saveError("FillMandatory", Msg.getElement(getCtx(), COLUMNNAME_M_AttributeSetInstance_ID)); - return false; + if (! product.getAttributeSet().excludeTableEntry(MInventoryLine.Table_ID, isSOTrx())) { + log.saveError("FillMandatory", Msg.getElement(getCtx(), COLUMNNAME_M_AttributeSetInstance_ID)); + return false; + } } } // No ASI - } // new or manual + } // manual // Set Line No if (getLine() == 0) @@ -423,12 +425,10 @@ public class MInventoryLine extends X_M_InventoryLine * @return true if is internal use inventory */ public boolean isInternalUseInventory() { - /* TODO: need to add M_Inventory.IsInternalUseInventory flag - see FR [ 1879029 ] Added IsInternalUseInventory flag to M_Inventory table - MInventory parent = getParent(); - return parent != null && parent.isInternalUseInventory(); - */ - return getQtyInternalUse().signum() != 0; + // IDEMPIERE-675 + MDocType dt = MDocType.get(getCtx(), getParent().getC_DocType_ID()); + String docSubTypeInv = dt.getDocSubTypeInv(); + return (MDocType.DOCSUBTYPEINV_InternalUseInventory.equals(docSubTypeInv)); } /** diff --git a/org.adempiere.base/src/org/compiere/model/MMovementLine.java b/org.adempiere.base/src/org/compiere/model/MMovementLine.java index b47398df55..05c063fc08 100644 --- a/org.adempiere.base/src/org/compiere/model/MMovementLine.java +++ b/org.adempiere.base/src/org/compiere/model/MMovementLine.java @@ -211,9 +211,11 @@ public class MMovementLine extends X_M_MovementLine // Mandatory Instance MProduct product = getProduct(); if (getM_AttributeSetInstance_ID() == 0) { - if (product != null && product.isASIMandatory(false)) { - log.saveError("FillMandatory", Msg.getElement(getCtx(), COLUMNNAME_M_AttributeSetInstance_ID)); - return false; + if (product != null && product.isASIMandatory(true)) { + if (! product.getAttributeSet().excludeTableEntry(MMovementLine.Table_ID, true /*outgoing*/)) { + log.saveError("FillMandatory", Msg.getElement(getCtx(), COLUMNNAME_M_AttributeSetInstance_ID)); + return false; + } } } if (getM_AttributeSetInstanceTo_ID() == 0) @@ -225,10 +227,12 @@ public class MMovementLine extends X_M_MovementLine setM_AttributeSetInstanceTo_ID(getM_AttributeSetInstance_ID()); } - if (product != null && product.isASIMandatory(true) && getM_AttributeSetInstanceTo_ID() == 0) + if (product != null && product.isASIMandatory(false) && getM_AttributeSetInstanceTo_ID() == 0) { - log.saveError("FillMandatory", Msg.getElement(getCtx(), COLUMNNAME_M_AttributeSetInstanceTo_ID)); - return false; + if (! product.getAttributeSet().excludeTableEntry(MMovementLine.Table_ID, false /*incoming*/)) { + log.saveError("FillMandatory", Msg.getElement(getCtx(), COLUMNNAME_M_AttributeSetInstanceTo_ID)); + return false; + } } } // ASI diff --git a/org.adempiere.base/src/org/compiere/model/MOrder.java b/org.adempiere.base/src/org/compiere/model/MOrder.java index e71c3fcf75..aa6eee8924 100644 --- a/org.adempiere.base/src/org/compiere/model/MOrder.java +++ b/org.adempiere.base/src/org/compiere/model/MOrder.java @@ -1310,19 +1310,21 @@ public class MOrder extends X_C_Order implements DocAction } // convert DocType // Mandatory Product Attribute Set Instance - String mandatoryType = "='Y'"; // IN ('Y','S') - String sql = "SELECT COUNT(*) " - + "FROM C_OrderLine ol" - + " INNER JOIN M_Product p ON (ol.M_Product_ID=p.M_Product_ID)" - + " INNER JOIN M_AttributeSet pas ON (p.M_AttributeSet_ID=pas.M_AttributeSet_ID) " - + "WHERE pas.MandatoryType" + mandatoryType - + " AND (ol.M_AttributeSetInstance_ID is NULL OR ol.M_AttributeSetInstance_ID = 0)" - + " AND ol.C_Order_ID=?"; - int no = DB.getSQLValue(get_TrxName(), sql, getC_Order_ID()); - if (no != 0) - { - m_processMsg = "@LinesWithoutProductAttribute@ (" + no + ")"; - return DocAction.STATUS_Invalid; + for (MOrderLine line : getLines()) { + if (line.getM_Product_ID() > 0 && line.getM_AttributeSetInstance_ID() == 0) { + MProduct product = line.getProduct(); + if (product.isASIMandatory(isSOTrx())) { + if (! product.getAttributeSet().excludeTableEntry(MOrderLine.Table_ID, isSOTrx())) { + StringBuilder msg = new StringBuilder("@M_AttributeSet_ID@ @IsMandatory@ (@Line@ #") + .append(line.getLine()) + .append(", @M_Product_ID@=") + .append(product.getValue()) + .append(")"); + m_processMsg = msg.toString(); + return DocAction.STATUS_Invalid; + } + } + } } // Lines