From ea40c1a8bf23499ca2b9e3f71d8d1c7805b4dc0b Mon Sep 17 00:00:00 2001 From: Carlos Ruiz Date: Sun, 17 Mar 2013 16:31:01 -0500 Subject: [PATCH] IDEMPIERE-661 OrderLineCreateProduction not passing accounting data from SO to Production --- .../oracle/201303131830_IDEMPIERE-661.sql | 21 ++++++++ .../postgresql/201303131830_IDEMPIERE-661.sql | 21 ++++++++ .../process/OrderLineCreateProduction.java | 49 +++++++++++++++++-- .../org/compiere/model/X_M_Production.java | 8 ++- 4 files changed, 94 insertions(+), 5 deletions(-) create mode 100644 migration/i1.0a-release/oracle/201303131830_IDEMPIERE-661.sql create mode 100644 migration/i1.0a-release/postgresql/201303131830_IDEMPIERE-661.sql diff --git a/migration/i1.0a-release/oracle/201303131830_IDEMPIERE-661.sql b/migration/i1.0a-release/oracle/201303131830_IDEMPIERE-661.sql new file mode 100644 index 0000000000..7b39c2dac9 --- /dev/null +++ b/migration/i1.0a-release/oracle/201303131830_IDEMPIERE-661.sql @@ -0,0 +1,21 @@ +-- Mar 13, 2013 4:02:09 PM COT +-- IDEMPIERE-661 OrderLineCreateProduction not passing accounting data from SO to Production +UPDATE AD_Column SET ColumnSQL=NULL, IsAllowCopy='N',Updated=TO_DATE('2013-03-13 16:02:09','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Column_ID=61942 +; + +-- Mar 13, 2013 4:02:19 PM COT +-- IDEMPIERE-661 OrderLineCreateProduction not passing accounting data from SO to Production +ALTER TABLE M_Production ADD C_BPartner_ID NUMBER(10) DEFAULT NULL +; + +update m_production +set c_bpartner_id=(select o.c_bpartner_id from c_order o join c_orderline ol on o.c_order_id=ol.c_order_id where ol.c_orderline_id=m_production.c_orderline_id) +where c_orderline_id>0 +; + +-- Mar 17, 2013 4:23:40 PM COT +UPDATE AD_Table SET AD_Window_ID=53127,Updated=TO_DATE('2013-03-17 16:23:40','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Table_ID=325 +; + +SELECT register_migration_script('201303131830_IDEMPIERE-661.sql') FROM dual +; diff --git a/migration/i1.0a-release/postgresql/201303131830_IDEMPIERE-661.sql b/migration/i1.0a-release/postgresql/201303131830_IDEMPIERE-661.sql new file mode 100644 index 0000000000..043f961525 --- /dev/null +++ b/migration/i1.0a-release/postgresql/201303131830_IDEMPIERE-661.sql @@ -0,0 +1,21 @@ +-- Mar 13, 2013 4:02:09 PM COT +-- IDEMPIERE-661 OrderLineCreateProduction not passing accounting data from SO to Production +UPDATE AD_Column SET ColumnSQL=NULL, IsAllowCopy='N',Updated=TO_TIMESTAMP('2013-03-13 16:02:09','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Column_ID=61942 +; + +-- Mar 13, 2013 4:02:19 PM COT +-- IDEMPIERE-661 OrderLineCreateProduction not passing accounting data from SO to Production +ALTER TABLE M_Production ADD COLUMN C_BPartner_ID NUMERIC(10) DEFAULT NULL +; + +update m_production +set c_bpartner_id=(select o.c_bpartner_id from c_order o join c_orderline ol on o.c_order_id=ol.c_order_id where ol.c_orderline_id=m_production.c_orderline_id) +where c_orderline_id>0 +; + +-- Mar 17, 2013 4:23:40 PM COT +UPDATE AD_Table SET AD_Window_ID=53127,Updated=TO_TIMESTAMP('2013-03-17 16:23:40','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Table_ID=325 +; + +SELECT register_migration_script('201303131830_IDEMPIERE-661.sql') FROM dual +; diff --git a/org.adempiere.base.process/src/org/compiere/process/OrderLineCreateProduction.java b/org.adempiere.base.process/src/org/compiere/process/OrderLineCreateProduction.java index b6c42baa37..a03e660521 100644 --- a/org.adempiere.base.process/src/org/compiere/process/OrderLineCreateProduction.java +++ b/org.adempiere.base.process/src/org/compiere/process/OrderLineCreateProduction.java @@ -27,6 +27,7 @@ import org.compiere.model.MProduction; import org.compiere.model.MWarehouse; import org.compiere.util.DB; import org.compiere.util.Env; +import org.compiere.util.Msg; /** * Create (Generate) Invoice from Shipment @@ -125,14 +126,56 @@ public class OrderLineCreateProduction extends SvrProcess if ( locator == 0 ) locator = MWarehouse.get(getCtx(), line.getM_Warehouse_ID()).getDefaultLocator().get_ID(); production.setM_Locator_ID(locator); + + if (line.getC_BPartner_ID() > 0) { + production.setC_BPartner_ID(order.getC_BPartner_ID()); + } + + if (line.getC_Project_ID() > 0 ) { + production.setC_Project_ID(line.getC_Project_ID()); + } else { + production.setC_Project_ID(order.getC_Project_ID()); + } + + if (line.getC_Campaign_ID() > 0) { + production.setC_Campaign_ID(line.getC_Campaign_ID()); + } else { + production.setC_Campaign_ID(order.getC_Campaign_ID()); + } + + if (line.getC_Activity_ID() > 0) { + production.setC_Activity_ID(line.getC_Activity_ID()); + } else { + production.setC_Activity_ID(order.getC_Activity_ID()); + } + + if (line.getUser1_ID() > 0) { + production.setUser1_ID(line.getUser1_ID()); + } else { + production.setUser1_ID(order.getUser1_ID()); + } + + if (line.getUser2_ID() > 0) { + production.setUser2_ID(line.getUser2_ID()); + } else { + production.setUser2_ID(order.getUser2_ID()); + } + + if (line.getAD_OrgTrx_ID() > 0) { + production.setAD_OrgTrx_ID(line.getAD_OrgTrx_ID()); + } else { + production.setAD_OrgTrx_ID(order.getAD_OrgTrx_ID()); + } + production.saveEx(); production.createLines(false); production.setIsCreated("Y"); production.saveEx(); - - StringBuilder msgreturn = new StringBuilder("Production created -- ").append(production.get_ValueAsString("DocumentNo")); - return msgreturn.toString(); + + String msg = Msg.parseTranslation(getCtx(), "@M_Production_ID@ @Created@ " + production.getDocumentNo()); + addLog(production.getM_Production_ID(), null, null, msg, MProduction.Table_ID, production.getM_Production_ID()); + return "@OK@"; } // OrderLineCreateShipment } // OrderLineCreateShipment diff --git a/org.adempiere.base/src/org/compiere/model/X_M_Production.java b/org.adempiere.base/src/org/compiere/model/X_M_Production.java index b9e820835d..19d94d5194 100644 --- a/org.adempiere.base/src/org/compiere/model/X_M_Production.java +++ b/org.adempiere.base/src/org/compiere/model/X_M_Production.java @@ -33,7 +33,7 @@ public class X_M_Production extends PO implements I_M_Production, I_Persistent /** * */ - private static final long serialVersionUID = 20121031L; + private static final long serialVersionUID = 20130317L; /** Standard Constructor */ public X_M_Production (Properties ctx, int M_Production_ID, String trxName) @@ -146,7 +146,11 @@ public class X_M_Production extends PO implements I_M_Production, I_Persistent */ public void setC_BPartner_ID (int C_BPartner_ID) { - throw new IllegalArgumentException ("C_BPartner_ID is virtual column"); } + if (C_BPartner_ID < 1) + set_ValueNoCheck (COLUMNNAME_C_BPartner_ID, null); + else + set_ValueNoCheck (COLUMNNAME_C_BPartner_ID, Integer.valueOf(C_BPartner_ID)); + } /** Get Business Partner . @return Identifies a Business Partner