From 464adfdec904056a359b54b1f9a09f5fff1fc974 Mon Sep 17 00:00:00 2001 From: Heng Sin Low Date: Thu, 6 Dec 2007 15:50:14 +0000 Subject: [PATCH] [ 1753074 ] Can't open attribute instance window for new product - better fix, don't have to auto save product first. --- .../src/org/compiere/grid/ed/VPAttribute.java | 18 ---------- .../compiere/grid/ed/VPAttributeDialog.java | 34 +++++++++++++------ 2 files changed, 23 insertions(+), 29 deletions(-) diff --git a/client/src/org/compiere/grid/ed/VPAttribute.java b/client/src/org/compiere/grid/ed/VPAttribute.java index cf37ad3bea..69e7c3fc7c 100644 --- a/client/src/org/compiere/grid/ed/VPAttribute.java +++ b/client/src/org/compiere/grid/ed/VPAttribute.java @@ -292,24 +292,6 @@ public class VPAttribute extends JComponent // Exclude ability to enter ASI boolean exclude = true; - //auto save for new product - if (M_Product_ID == 0) - { - JFrame frame = Env.getWindow(m_WindowNo); - if (frame instanceof AWindow) - { - AWindow aWindow = (AWindow)frame; - if (aWindow.getAPanel().getCurrentTab().getTableName().equalsIgnoreCase("M_Product")) - { - if (aWindow.getAPanel().cmd_save(true)) - { - Object value = aWindow.getAPanel().getCurrentTab().getValue("M_Product_ID"); - if (value != null && value instanceof Integer) - M_Product_ID = ((Integer)value).intValue(); - } - } - } - } if (M_Product_ID != 0) { diff --git a/client/src/org/compiere/grid/ed/VPAttributeDialog.java b/client/src/org/compiere/grid/ed/VPAttributeDialog.java index c88b72ce25..9de4c820f7 100644 --- a/client/src/org/compiere/grid/ed/VPAttributeDialog.java +++ b/client/src/org/compiere/grid/ed/VPAttributeDialog.java @@ -148,20 +148,32 @@ public class VPAttributeDialog extends CDialog */ private boolean initAttributes () { - if (m_M_Product_ID == 0) + if (m_M_Product_ID == 0 && !m_productWindow) return false; - - // Get Model - m_masi = MAttributeSetInstance.get(Env.getCtx(), m_M_AttributeSetInstance_ID, m_M_Product_ID); - if (m_masi == null) + + MAttributeSet as = null; + + if (m_M_Product_ID != 0) { - log.severe ("No Model for M_AttributeSetInstance_ID=" + m_M_AttributeSetInstance_ID + ", M_Product_ID=" + m_M_Product_ID); - return false; + // Get Model + m_masi = MAttributeSetInstance.get(Env.getCtx(), m_M_AttributeSetInstance_ID, m_M_Product_ID); + if (m_masi == null) + { + log.severe ("No Model for M_AttributeSetInstance_ID=" + m_M_AttributeSetInstance_ID + ", M_Product_ID=" + m_M_Product_ID); + return false; + } + Env.setContext(Env.getCtx(), m_WindowNo, "M_AttributeSet_ID", m_masi.getM_AttributeSet_ID()); + + // Get Attribute Set + as = m_masi.getMAttributeSet(); } - Env.setContext(Env.getCtx(), m_WindowNo, "M_AttributeSet_ID", m_masi.getM_AttributeSet_ID()); - - // Get Attribute Set - MAttributeSet as = m_masi.getMAttributeSet(); + else + { + int M_AttributeSet_ID = Env.getContextAsInt(Env.getCtx(), m_WindowNoParent, "M_AttributeSet_ID"); + m_masi = new MAttributeSetInstance (Env.getCtx(), 0, M_AttributeSet_ID, null); + as = m_masi.getMAttributeSet(); + } + // Product has no Attribute Set if (as == null) {