From 205803a089ffa14d23e6dbed8ec9191b7dc9cebc Mon Sep 17 00:00:00 2001 From: Carlos Ruiz Date: Thu, 14 Feb 2013 13:28:05 -0500 Subject: [PATCH] IDEMPIERE-589 Add DocAction to Import Inventory / Peer review --- .../oracle/2013020830719_IDEMPIERE-589.sql | 92 +++++++++++++++++- .../2013020830719_IDEMPIERE-589.sql | 93 ++++++++++++++++++- .../org/compiere/process/ImportInventory.java | 43 ++++++--- 3 files changed, 212 insertions(+), 16 deletions(-) diff --git a/migration/i1.0a-release/oracle/2013020830719_IDEMPIERE-589.sql b/migration/i1.0a-release/oracle/2013020830719_IDEMPIERE-589.sql index fe8c5e8ebe..cce9b6b565 100644 --- a/migration/i1.0a-release/oracle/2013020830719_IDEMPIERE-589.sql +++ b/migration/i1.0a-release/oracle/2013020830719_IDEMPIERE-589.sql @@ -8,5 +8,95 @@ INSERT INTO AD_Process_Para (IsRange,AD_Element_ID,AD_Process_Para_ID,AD_Process INSERT INTO AD_Process_Para_Trl (AD_Language,AD_Process_Para_ID, Help,Name,Description, IsTranslated,AD_Client_ID,AD_Org_ID,Created,Createdby,Updated,UpdatedBy,AD_Process_Para_Trl_UU ) SELECT l.AD_Language,t.AD_Process_Para_ID, t.Help,t.Name,t.Description, 'N',t.AD_Client_ID,t.AD_Org_ID,t.Created,t.Createdby,t.Updated,t.UpdatedBy,Generate_UUID() FROM AD_Language l, AD_Process_Para t WHERE l.IsActive='Y' AND l.IsSystemLanguage='Y' AND l.IsBaseLanguage='N' AND t.AD_Process_Para_ID=200050 AND NOT EXISTS (SELECT * FROM AD_Process_Para_Trl tt WHERE tt.AD_Language=l.AD_Language AND tt.AD_Process_Para_ID=t.AD_Process_Para_ID) ; -SELECT register_migration_script('IDEMPIERE-589.sql') FROM dual +-- Feb 14, 2013 12:49:13 PM COT +-- IDEMPIERE-589 Add DocAction to Import Inventory +UPDATE AD_WorkflowProcessor SET DateNextRun=TO_DATE('2013-02-14 14:49:13','YYYY-MM-DD HH24:MI:SS'), DateLastRun=TO_DATE('2013-02-14 12:49:13','YYYY-MM-DD HH24:MI:SS'),Updated=TO_DATE('2013-02-14 12:49:13','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_WorkflowProcessor_ID=100 +; + +-- Feb 14, 2013 12:49:13 PM COT +-- IDEMPIERE-589 Add DocAction to Import Inventory +UPDATE AD_Process_Para SET AD_Val_Rule_ID=52027, DefaultValue=NULL,Updated=TO_DATE('2013-02-14 12:49:13','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Process_Para_ID=200050 +; + +-- Feb 14, 2013 12:49:46 PM COT +-- IDEMPIERE-589 Add DocAction to Import Inventory +UPDATE AD_Process_Para SET SeqNo=110,Updated=TO_DATE('2013-02-14 12:49:46','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Process_Para_ID=53378 +; + +-- Feb 14, 2013 12:49:49 PM COT +-- IDEMPIERE-589 Add DocAction to Import Inventory +UPDATE AD_Process_Para SET SeqNo=100,Updated=TO_DATE('2013-02-14 12:49:49','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Process_Para_ID=53377 +; + +-- Feb 14, 2013 12:49:53 PM COT +-- IDEMPIERE-589 Add DocAction to Import Inventory +UPDATE AD_Process_Para SET SeqNo=90,Updated=TO_DATE('2013-02-14 12:49:53','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Process_Para_ID=53376 +; + +-- Feb 14, 2013 12:49:58 PM COT +-- IDEMPIERE-589 Add DocAction to Import Inventory +UPDATE AD_Process_Para SET SeqNo=80,Updated=TO_DATE('2013-02-14 12:49:58','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Process_Para_ID=53375 +; + +-- Feb 14, 2013 12:50:02 PM COT +-- IDEMPIERE-589 Add DocAction to Import Inventory +UPDATE AD_Process_Para SET SeqNo=70,Updated=TO_DATE('2013-02-14 12:50:02','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Process_Para_ID=53374 +; + +-- Feb 14, 2013 12:50:06 PM COT +-- IDEMPIERE-589 Add DocAction to Import Inventory +UPDATE AD_Process_Para SET SeqNo=60,Updated=TO_DATE('2013-02-14 12:50:06','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Process_Para_ID=327 +; + +-- Feb 14, 2013 12:50:10 PM COT +-- IDEMPIERE-589 Add DocAction to Import Inventory +UPDATE AD_Process_Para SET SeqNo=50,Updated=TO_DATE('2013-02-14 12:50:10','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Process_Para_ID=337 +; + +-- Feb 14, 2013 12:50:14 PM COT +-- IDEMPIERE-589 Add DocAction to Import Inventory +UPDATE AD_Process_Para SET SeqNo=40,Updated=TO_DATE('2013-02-14 12:50:14','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Process_Para_ID=200050 +; + +-- Feb 14, 2013 1:26:53 PM COT +-- IDEMPIERE-589 Add DocAction to Import Inventory +UPDATE AD_Element SET Name='Document Action',Updated=TO_DATE('2013-02-14 13:26:53','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Element_ID=287 +; + +-- Feb 14, 2013 1:26:53 PM COT +-- IDEMPIERE-589 Add DocAction to Import Inventory +UPDATE AD_Element_Trl SET IsTranslated='N' WHERE AD_Element_ID=287 +; + +-- Feb 14, 2013 1:26:53 PM COT +-- IDEMPIERE-589 Add DocAction to Import Inventory +UPDATE AD_Column SET ColumnName='DocAction', Name='Document Action', Description='The targeted status of the document', Help='You find the current status in the Document Status field. The options are listed in a popup' WHERE AD_Element_ID=287 +; + +-- Feb 14, 2013 1:26:53 PM COT +-- IDEMPIERE-589 Add DocAction to Import Inventory +UPDATE AD_Process_Para SET ColumnName='DocAction', Name='Document Action', Description='The targeted status of the document', Help='You find the current status in the Document Status field. The options are listed in a popup', AD_Element_ID=287 WHERE UPPER(ColumnName)='DOCACTION' AND IsCentrallyMaintained='Y' AND AD_Element_ID IS NULL +; + +-- Feb 14, 2013 1:26:53 PM COT +-- IDEMPIERE-589 Add DocAction to Import Inventory +UPDATE AD_Process_Para SET ColumnName='DocAction', Name='Document Action', Description='The targeted status of the document', Help='You find the current status in the Document Status field. The options are listed in a popup' WHERE AD_Element_ID=287 AND IsCentrallyMaintained='Y' +; + +-- Feb 14, 2013 1:26:53 PM COT +-- IDEMPIERE-589 Add DocAction to Import Inventory +UPDATE AD_InfoColumn SET ColumnName='DocAction', Name='Document Action', Description='The targeted status of the document', Help='You find the current status in the Document Status field. The options are listed in a popup' WHERE AD_Element_ID=287 AND IsCentrallyMaintained='Y' +; + +-- Feb 14, 2013 1:26:53 PM COT +-- IDEMPIERE-589 Add DocAction to Import Inventory +UPDATE AD_Field SET Name='Document Action', Description='The targeted status of the document', Help='You find the current status in the Document Status field. The options are listed in a popup' WHERE AD_Column_ID IN (SELECT AD_Column_ID FROM AD_Column WHERE AD_Element_ID=287) AND IsCentrallyMaintained='Y' +; + +-- Feb 14, 2013 1:26:53 PM COT +-- IDEMPIERE-589 Add DocAction to Import Inventory +UPDATE AD_PrintFormatItem pi SET PrintName='Doc Action', Name='Document Action' WHERE IsCentrallyMaintained='Y' AND EXISTS (SELECT * FROM AD_Column c WHERE c.AD_Column_ID=pi.AD_Column_ID AND c.AD_Element_ID=287) +; + +SELECT register_migration_script('2013020830719_IDEMPIERE-589.sql') FROM dual ; diff --git a/migration/i1.0a-release/postgresql/2013020830719_IDEMPIERE-589.sql b/migration/i1.0a-release/postgresql/2013020830719_IDEMPIERE-589.sql index 593579e390..c26d0e31f9 100644 --- a/migration/i1.0a-release/postgresql/2013020830719_IDEMPIERE-589.sql +++ b/migration/i1.0a-release/postgresql/2013020830719_IDEMPIERE-589.sql @@ -8,6 +8,95 @@ INSERT INTO AD_Process_Para (IsRange,AD_Element_ID,AD_Process_Para_ID,AD_Process INSERT INTO AD_Process_Para_Trl (AD_Language,AD_Process_Para_ID, Help,Name,Description, IsTranslated,AD_Client_ID,AD_Org_ID,Created,Createdby,Updated,UpdatedBy,AD_Process_Para_Trl_UU ) SELECT l.AD_Language,t.AD_Process_Para_ID, t.Help,t.Name,t.Description, 'N',t.AD_Client_ID,t.AD_Org_ID,t.Created,t.Createdby,t.Updated,t.UpdatedBy,Generate_UUID() FROM AD_Language l, AD_Process_Para t WHERE l.IsActive='Y' AND l.IsSystemLanguage='Y' AND l.IsBaseLanguage='N' AND t.AD_Process_Para_ID=200050 AND NOT EXISTS (SELECT * FROM AD_Process_Para_Trl tt WHERE tt.AD_Language=l.AD_Language AND tt.AD_Process_Para_ID=t.AD_Process_Para_ID) ; - -SELECT register_migration_script('IDEMPIERE-589.sql') FROM dual +-- Feb 14, 2013 12:49:13 PM COT +-- IDEMPIERE-589 Add DocAction to Import Inventory +UPDATE AD_WorkflowProcessor SET DateNextRun=TO_TIMESTAMP('2013-02-14 14:49:13','YYYY-MM-DD HH24:MI:SS'), DateLastRun=TO_TIMESTAMP('2013-02-14 12:49:13','YYYY-MM-DD HH24:MI:SS'),Updated=TO_TIMESTAMP('2013-02-14 12:49:13','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_WorkflowProcessor_ID=100 +; + +-- Feb 14, 2013 12:49:13 PM COT +-- IDEMPIERE-589 Add DocAction to Import Inventory +UPDATE AD_Process_Para SET AD_Val_Rule_ID=52027, DefaultValue=NULL,Updated=TO_TIMESTAMP('2013-02-14 12:49:13','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Process_Para_ID=200050 +; + +-- Feb 14, 2013 12:49:46 PM COT +-- IDEMPIERE-589 Add DocAction to Import Inventory +UPDATE AD_Process_Para SET SeqNo=110,Updated=TO_TIMESTAMP('2013-02-14 12:49:46','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Process_Para_ID=53378 +; + +-- Feb 14, 2013 12:49:49 PM COT +-- IDEMPIERE-589 Add DocAction to Import Inventory +UPDATE AD_Process_Para SET SeqNo=100,Updated=TO_TIMESTAMP('2013-02-14 12:49:49','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Process_Para_ID=53377 +; + +-- Feb 14, 2013 12:49:53 PM COT +-- IDEMPIERE-589 Add DocAction to Import Inventory +UPDATE AD_Process_Para SET SeqNo=90,Updated=TO_TIMESTAMP('2013-02-14 12:49:53','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Process_Para_ID=53376 +; + +-- Feb 14, 2013 12:49:58 PM COT +-- IDEMPIERE-589 Add DocAction to Import Inventory +UPDATE AD_Process_Para SET SeqNo=80,Updated=TO_TIMESTAMP('2013-02-14 12:49:58','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Process_Para_ID=53375 +; + +-- Feb 14, 2013 12:50:02 PM COT +-- IDEMPIERE-589 Add DocAction to Import Inventory +UPDATE AD_Process_Para SET SeqNo=70,Updated=TO_TIMESTAMP('2013-02-14 12:50:02','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Process_Para_ID=53374 +; + +-- Feb 14, 2013 12:50:06 PM COT +-- IDEMPIERE-589 Add DocAction to Import Inventory +UPDATE AD_Process_Para SET SeqNo=60,Updated=TO_TIMESTAMP('2013-02-14 12:50:06','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Process_Para_ID=327 +; + +-- Feb 14, 2013 12:50:10 PM COT +-- IDEMPIERE-589 Add DocAction to Import Inventory +UPDATE AD_Process_Para SET SeqNo=50,Updated=TO_TIMESTAMP('2013-02-14 12:50:10','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Process_Para_ID=337 +; + +-- Feb 14, 2013 12:50:14 PM COT +-- IDEMPIERE-589 Add DocAction to Import Inventory +UPDATE AD_Process_Para SET SeqNo=40,Updated=TO_TIMESTAMP('2013-02-14 12:50:14','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Process_Para_ID=200050 +; + +-- Feb 14, 2013 1:26:53 PM COT +-- IDEMPIERE-589 Add DocAction to Import Inventory +UPDATE AD_Element SET Name='Document Action',Updated=TO_TIMESTAMP('2013-02-14 13:26:53','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Element_ID=287 +; + +-- Feb 14, 2013 1:26:53 PM COT +-- IDEMPIERE-589 Add DocAction to Import Inventory +UPDATE AD_Element_Trl SET IsTranslated='N' WHERE AD_Element_ID=287 +; + +-- Feb 14, 2013 1:26:53 PM COT +-- IDEMPIERE-589 Add DocAction to Import Inventory +UPDATE AD_Column SET ColumnName='DocAction', Name='Document Action', Description='The targeted status of the document', Help='You find the current status in the Document Status field. The options are listed in a popup' WHERE AD_Element_ID=287 +; + +-- Feb 14, 2013 1:26:53 PM COT +-- IDEMPIERE-589 Add DocAction to Import Inventory +UPDATE AD_Process_Para SET ColumnName='DocAction', Name='Document Action', Description='The targeted status of the document', Help='You find the current status in the Document Status field. The options are listed in a popup', AD_Element_ID=287 WHERE UPPER(ColumnName)='DOCACTION' AND IsCentrallyMaintained='Y' AND AD_Element_ID IS NULL +; + +-- Feb 14, 2013 1:26:53 PM COT +-- IDEMPIERE-589 Add DocAction to Import Inventory +UPDATE AD_Process_Para SET ColumnName='DocAction', Name='Document Action', Description='The targeted status of the document', Help='You find the current status in the Document Status field. The options are listed in a popup' WHERE AD_Element_ID=287 AND IsCentrallyMaintained='Y' +; + +-- Feb 14, 2013 1:26:53 PM COT +-- IDEMPIERE-589 Add DocAction to Import Inventory +UPDATE AD_InfoColumn SET ColumnName='DocAction', Name='Document Action', Description='The targeted status of the document', Help='You find the current status in the Document Status field. The options are listed in a popup' WHERE AD_Element_ID=287 AND IsCentrallyMaintained='Y' +; + +-- Feb 14, 2013 1:26:53 PM COT +-- IDEMPIERE-589 Add DocAction to Import Inventory +UPDATE AD_Field SET Name='Document Action', Description='The targeted status of the document', Help='You find the current status in the Document Status field. The options are listed in a popup' WHERE AD_Column_ID IN (SELECT AD_Column_ID FROM AD_Column WHERE AD_Element_ID=287) AND IsCentrallyMaintained='Y' +; + +-- Feb 14, 2013 1:26:53 PM COT +-- IDEMPIERE-589 Add DocAction to Import Inventory +UPDATE AD_PrintFormatItem SET PrintName='Doc Action', Name='Document Action' WHERE IsCentrallyMaintained='Y' AND EXISTS (SELECT * FROM AD_Column c WHERE c.AD_Column_ID=AD_PrintFormatItem.AD_Column_ID AND c.AD_Element_ID=287) +; + +SELECT register_migration_script('2013020830719_IDEMPIERE-589.sql') FROM dual ; diff --git a/org.adempiere.base.process/src/org/compiere/process/ImportInventory.java b/org.adempiere.base.process/src/org/compiere/process/ImportInventory.java index 5abd12bae8..1b499163d0 100644 --- a/org.adempiere.base.process/src/org/compiere/process/ImportInventory.java +++ b/org.adempiere.base.process/src/org/compiere/process/ImportInventory.java @@ -70,7 +70,7 @@ public class ImportInventory extends SvrProcess /** Organization for which Costing record must be updated */ private int p_AD_OrgTrx_ID = 0; /** Document Action */ - private String m_docAction = MInventory.DOCACTION_Prepare; + private String m_docAction = null; /** * Prepare - e.g., get Parameters. @@ -322,10 +322,12 @@ public class ImportInventory extends SvrProcess sql = new StringBuilder ("SELECT * FROM I_Inventory ") .append("WHERE I_IsImported='N'").append (clientCheck) .append(" ORDER BY M_Warehouse_ID, TRUNC(MovementDate), I_Inventory_ID"); + PreparedStatement pstmt = null; + ResultSet rs = null; try { - PreparedStatement pstmt = DB.prepareStatement (sql.toString (), get_TrxName()); - ResultSet rs = pstmt.executeQuery (); + pstmt = DB.prepareStatement (sql.toString (), get_TrxName()); + rs = pstmt.executeQuery (); // int x_M_Warehouse_ID = -1; int x_C_DocType_ID = -1; @@ -343,6 +345,16 @@ public class ImportInventory extends SvrProcess || !MovementDate.equals(x_MovementDate) || isInternalUse != x_isInternalUse) { + if (inventory != null) { + if (m_docAction != null && m_docAction.length() > 0) { + if (!inventory.processIt(m_docAction)) { + log.warning("Inventory Process Failed: " + inventory + " - " + inventory.getProcessMsg()); + throw new IllegalStateException("Inventory Process Failed: " + inventory + " - " + inventory.getProcessMsg()); + + } + inventory.saveEx(); + } + } inventory = new MInventory (getCtx(), 0, get_TrxName()); if (imp.getC_DocType_ID() > 0) inventory.setC_DocType_ID(imp.getC_DocType_ID()); @@ -362,14 +374,6 @@ public class ImportInventory extends SvrProcess x_isInternalUse = isInternalUse; noInsert++; } - else if (inventory != null){ - if (!inventory.processIt(m_docAction)) { - log.warning("Inventory Process Failed: " + inventory + " - " + inventory.getProcessMsg()); - throw new IllegalStateException("Inventory Process Failed: " + inventory + " - " + inventory.getProcessMsg()); - - } - inventory.saveEx(); - } MProduct product = MProduct.get(getCtx(), imp.getM_Product_ID()); // Line int M_AttributeSetInstance_ID = 0; @@ -434,13 +438,26 @@ public class ImportInventory extends SvrProcess } } } - rs.close(); - pstmt.close(); + if (inventory != null) { + if (m_docAction != null && m_docAction.length() > 0) { + if (!inventory.processIt(m_docAction)) { + log.warning("Inventory Process Failed: " + inventory + " - " + inventory.getProcessMsg()); + throw new IllegalStateException("Inventory Process Failed: " + inventory + " - " + inventory.getProcessMsg()); + + } + inventory.saveEx(); + } + } } catch (Exception e) { throw new AdempiereException(e); } + finally + { + DB.close(rs, pstmt); + rs = null; pstmt = null; + } // Set Error to indicator to not imported sql = new StringBuilder ("UPDATE I_Inventory ")