From f13092548fe5d8f3959b6eeafccd11222092f0c8 Mon Sep 17 00:00:00 2001 From: Carlos Ruiz Date: Mon, 26 Nov 2012 13:44:35 -0500 Subject: [PATCH 1/4] IDEMPIERE-246 Integrate Manufacturing Light / Fixes: - bug on cost difference calculation - make the creation of production lines according with iDempiere architecture (configurable via sysconfig) - must not require accounting consequences to create production lines --- .../compiere/process/ProductionCreate.java | 21 ++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/org.adempiere.base.process/src/org/compiere/process/ProductionCreate.java b/org.adempiere.base.process/src/org/compiere/process/ProductionCreate.java index f1b23b0ea5..2ff78d2986 100644 --- a/org.adempiere.base.process/src/org/compiere/process/ProductionCreate.java +++ b/org.adempiere.base.process/src/org/compiere/process/ProductionCreate.java @@ -4,8 +4,10 @@ import java.math.BigDecimal; import java.util.logging.Level; import org.compiere.model.MProduction; +import org.compiere.model.MSysConfig; import org.compiere.util.AdempiereUserError; import org.compiere.util.DB; +import org.compiere.util.Env; /** @@ -62,6 +64,7 @@ public class ProductionCreate extends SvrProcess { String sql = "SELECT ABS(((cc.currentcostprice-(SELECT SUM(c.currentcostprice*bom.bomqty)" + " FROM m_cost c" + " INNER JOIN m_product_bom bom ON (c.m_product_id=bom.m_productbom_id)" + + " INNER JOIN m_costelement ce ON (c.m_costelement_id = ce.m_costelement_id AND ce.costingmethod = 'S')" + " WHERE bom.m_product_id = pp.m_product_id)" + " )/cc.currentcostprice))" + " FROM m_product pp" @@ -74,7 +77,13 @@ public class ProductionCreate extends SvrProcess { if (costPercentageDiff == null) { - throw new AdempiereUserError("Could not retrieve costs"); + costPercentageDiff = Env.ZERO; + String msg = "Could not retrieve costs"; + if (MSysConfig.getBooleanValue("MFG_ValidateCostsOnCreate", false, getAD_Client_ID())) { + throw new AdempiereUserError(msg); + } else { + log.warning(msg); + } } if ( (costPercentageDiff.compareTo(new BigDecimal("0.005")))< 0 ) @@ -88,10 +97,16 @@ public class ProductionCreate extends SvrProcess { int created = 0; isBom(m_production.getM_Product_ID()); - if (!costsOK(m_production.getM_Product_ID())) + if (!costsOK(m_production.getM_Product_ID())) { + String msg = "Excessive difference in standard costs"; + if (MSysConfig.getBooleanValue("MFG_ValidateCostsDifferenceOnCreate", false, getAD_Client_ID())) { throw new AdempiereUserError("Excessive difference in standard costs"); + } else { + log.warning(msg); + } + } - if (!recreate && "true".equalsIgnoreCase(m_production.get_ValueAsString("IsCreated"))) + if (!recreate && "Y".equalsIgnoreCase(m_production.getIsCreated())) throw new AdempiereUserError("Production already created."); if (newQty != null ) From 51525163ee7a62badb5cad94e1e2b304c1f157af Mon Sep 17 00:00:00 2001 From: Carlos Ruiz Date: Mon, 26 Nov 2012 13:58:24 -0500 Subject: [PATCH 2/4] IDEMPIERE-509 Problem in create new record in the window Production / Thanks to Tony Snook for suggested solution --- .../oracle/201211261356_IDEMPIERE-509.sql | 13 +++++++++++++ .../postgresql/201211261356_IDEMPIERE-509.sql | 13 +++++++++++++ 2 files changed, 26 insertions(+) create mode 100644 migration/i1.0a-release/oracle/201211261356_IDEMPIERE-509.sql create mode 100644 migration/i1.0a-release/postgresql/201211261356_IDEMPIERE-509.sql diff --git a/migration/i1.0a-release/oracle/201211261356_IDEMPIERE-509.sql b/migration/i1.0a-release/oracle/201211261356_IDEMPIERE-509.sql new file mode 100644 index 0000000000..d21cf0340f --- /dev/null +++ b/migration/i1.0a-release/oracle/201211261356_IDEMPIERE-509.sql @@ -0,0 +1,13 @@ +-- Nov 26, 2012 1:55:57 PM COT +-- IDEMPIERE-509 Problem in create new record in the window Production +UPDATE AD_Menu SET IsActive='N',Updated=TO_DATE('2012-11-26 13:55:57','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Menu_ID=228 +; + +-- Nov 26, 2012 1:56:13 PM COT +-- IDEMPIERE-509 Problem in create new record in the window Production +UPDATE AD_Window SET IsActive='N',Updated=TO_DATE('2012-11-26 13:56:13','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Window_ID=191 +; + +SELECT register_migration_script('201211261356_IDEMPIERE-509.sql') FROM dual +; + diff --git a/migration/i1.0a-release/postgresql/201211261356_IDEMPIERE-509.sql b/migration/i1.0a-release/postgresql/201211261356_IDEMPIERE-509.sql new file mode 100644 index 0000000000..e39bb3b488 --- /dev/null +++ b/migration/i1.0a-release/postgresql/201211261356_IDEMPIERE-509.sql @@ -0,0 +1,13 @@ +-- Nov 26, 2012 1:55:57 PM COT +-- IDEMPIERE-509 Problem in create new record in the window Production +UPDATE AD_Menu SET IsActive='N',Updated=TO_TIMESTAMP('2012-11-26 13:55:57','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Menu_ID=228 +; + +-- Nov 26, 2012 1:56:13 PM COT +-- IDEMPIERE-509 Problem in create new record in the window Production +UPDATE AD_Window SET IsActive='N',Updated=TO_TIMESTAMP('2012-11-26 13:56:13','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Window_ID=191 +; + +SELECT register_migration_script('201211261356_IDEMPIERE-509.sql') FROM dual +; + From 6e2cdb995886697727887d304f3d73b568ed5e24 Mon Sep 17 00:00:00 2001 From: Carlos Ruiz Date: Mon, 26 Nov 2012 15:04:11 -0500 Subject: [PATCH 3/4] IDEMPIERE-491 Caching data can generate problem / Fix problems with swing client not starting with postgres and throwing NPE --- .../src/org/compiere/db/CConnection.java | 3 ++- .../server.product.launch | 2 +- .../swingclient.product.launch | 4 ++-- .../hazelcast/service/CacheServiceImpl.java | 15 ++++++++++++--- 4 files changed, 17 insertions(+), 7 deletions(-) diff --git a/org.adempiere.base/src/org/compiere/db/CConnection.java b/org.adempiere.base/src/org/compiere/db/CConnection.java index e86e86e192..df891990ac 100644 --- a/org.adempiere.base/src/org/compiere/db/CConnection.java +++ b/org.adempiere.base/src/org/compiere/db/CConnection.java @@ -926,7 +926,8 @@ public class CConnection implements Serializable, Cloneable if (!retest && m_ds != null && m_okDB) return null; - getDatabase().close(); + if (getDatabase() != null) + getDatabase().close(); m_ds = null; setDataSource(); // the actual test diff --git a/org.adempiere.server-feature/server.product.launch b/org.adempiere.server-feature/server.product.launch index 5e499556e9..90ebb8c63a 100644 --- a/org.adempiere.server-feature/server.product.launch +++ b/org.adempiere.server-feature/server.product.launch @@ -21,7 +21,7 @@ - + diff --git a/org.adempiere.ui.swing-feature/swingclient.product.launch b/org.adempiere.ui.swing-feature/swingclient.product.launch index d94907060b..8d6b499243 100644 --- a/org.adempiere.ui.swing-feature/swingclient.product.launch +++ b/org.adempiere.ui.swing-feature/swingclient.product.launch @@ -21,8 +21,8 @@ - - + + diff --git a/org.idempiere.hazelcast.service/src/org/idempiere/hazelcast/service/CacheServiceImpl.java b/org.idempiere.hazelcast.service/src/org/idempiere/hazelcast/service/CacheServiceImpl.java index c9f9b10301..f8cc75a3bf 100644 --- a/org.idempiere.hazelcast.service/src/org/idempiere/hazelcast/service/CacheServiceImpl.java +++ b/org.idempiere.hazelcast.service/src/org/idempiere/hazelcast/service/CacheServiceImpl.java @@ -36,17 +36,26 @@ public class CacheServiceImpl implements ICacheService { */ @Override public Map getMap(String name) { - return Activator.hazelcastInstance.getMap(name); + if (Activator.hazelcastInstance != null) + return Activator.hazelcastInstance.getMap(name); + else + return null; } @Override public List getList(String name) { - return Activator.hazelcastInstance.getList(name); + if (Activator.hazelcastInstance != null) + return Activator.hazelcastInstance.getList(name); + else + return null; } @Override public Set getSet(String name) { - return Activator.hazelcastInstance.getSet(name); + if (Activator.hazelcastInstance != null) + return Activator.hazelcastInstance.getSet(name); + else + return null; } } From 06b2249b08fdc5e4a1eb1d2a9b5a84b44fd4a4b4 Mon Sep 17 00:00:00 2001 From: Carlos Ruiz Date: Mon, 26 Nov 2012 15:20:23 -0500 Subject: [PATCH 4/4] Stop NPE messages on performance indicators --- .../org/adempiere/webui/dashboard/DPPerformance.java | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/dashboard/DPPerformance.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/dashboard/DPPerformance.java index 7ebd941d39..c5d9c38042 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/dashboard/DPPerformance.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/dashboard/DPPerformance.java @@ -17,6 +17,7 @@ import org.adempiere.webui.apps.graph.WPAPanel; import org.adempiere.webui.util.ServerPushTemplate; import org.zkoss.zk.au.out.AuScript; import org.zkoss.zk.ui.Component; +import org.zkoss.zk.ui.Executions; import org.zkoss.zk.ui.Page; import org.zkoss.zk.ui.event.Events; import org.zkoss.zk.ui.util.Clients; @@ -46,14 +47,16 @@ public class DPPerformance extends DashboardPanel { public void refresh(ServerPushTemplate template) { super.refresh(template); - Events.echoEvent("onPostRender", this, null); + if (Executions.getCurrent() != null) + Events.echoEvent("onPostRender", this, null); } @Override public void onPageAttached(Page newpage, Page oldpage) { super.onPageAttached(newpage, oldpage); if (newpage != null) { - Events.echoEvent("onPostRender", this, null); + if (Executions.getCurrent() != null) + Events.echoEvent("onPostRender", this, null); } } @@ -63,6 +66,7 @@ public class DPPerformance extends DashboardPanel { Component grid = this.getFirstChild().getFirstChild(); String script = "setTimeout(function() { var grid = jq('#" + grid.getUuid() + "');"; script = script + "grid.parent().height(grid.css('height'));}, 500);"; - Clients.response(new AuScript(script)); + if (Executions.getCurrent() != null) + Clients.response(new AuScript(script)); } }