IDEMPIERE-1026 Button on table to create automatically the window (#128)

* IDEMPIERE-1026 Button on table to create automatically the window

* IDEMPIERE-1026 Button on table to create automatically the window - Fixed script

* IDEMPIERE-1026 Button on table to create automatically the window - Header update

* IDEMPIERE-1026 Button on table to create automatically the window - Follow best practices, no hardcoded IDs, no mixed cache and transaction

* IDEMPIERE-1026 Button on table to create automatically the window - Carlos PR
This commit is contained in:
Diego Ruiz 2020-06-24 16:43:11 +02:00 committed by GitHub
parent f5518a9b64
commit f50425334f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 458 additions and 0 deletions

View File

@ -0,0 +1,94 @@
SET SQLBLANKLINES ON
SET DEFINE OFF
-- IDEMPIERE-1026 Button on table to create automatically the window
-- Jun 19, 2020, 10:31:17 AM CEST
INSERT INTO AD_Process (AD_Process_ID,AD_Client_ID,AD_Org_ID,IsActive,Created,CreatedBy,Updated,UpdatedBy,Name,Description,Help,IsReport,Value,IsDirectPrint,Classname,AccessLevel,EntityType,Statistic_Count,Statistic_Seconds,IsBetaFunctionality,IsServerProcess,ShowHelp,CopyFromProcess,AD_Process_UU,AllowMultipleExecution) VALUES (200118,0,0,'Y',TO_DATE('2020-06-19 10:31:16','YYYY-MM-DD HH24:MI:SS'),100,TO_DATE('2020-06-19 10:31:16','YYYY-MM-DD HH24:MI:SS'),100,'Create Window, Tab & Field from Table','Create Window, Tab & Field record of the Table','This process will take the table definition and create the Window/Tab and field record with these options:<br>
New Window: if selected the process will create a new Window record. Otherwise, the process will create a new tab and add it to the selected window.<br>
Create Menu: if selected the process creates the menu record for the new window.','N','AD_Table_CreateWindow','N','org.compiere.process.CreateWindowFromTable','4','D',0,0,'N','N','Y','N','b1753358-c7dd-4387-ab99-355d081a5de2','P')
;
-- Jun 19, 2020, 10:35:37 AM CEST
INSERT INTO AD_Element (AD_Element_ID,AD_Client_ID,AD_Org_ID,IsActive,Created,CreatedBy,Updated,UpdatedBy,ColumnName,Name,Description,PrintName,EntityType,AD_Element_UU) VALUES (203419,0,0,'Y',TO_DATE('2020-06-19 10:35:36','YYYY-MM-DD HH24:MI:SS'),100,TO_DATE('2020-06-19 10:35:36','YYYY-MM-DD HH24:MI:SS'),100,'IsNewWindow','New Window','Defines if it creates a new window record or creates a new tab on an existing window','New Window','D','27a201ff-ce4c-4c82-a218-201e84c621cd')
;
-- Jun 19, 2020, 10:36:10 AM CEST
INSERT INTO AD_Process_Para (AD_Process_Para_ID,AD_Client_ID,AD_Org_ID,IsActive,Created,CreatedBy,Updated,UpdatedBy,Name,Description,AD_Process_ID,SeqNo,AD_Reference_ID,IsRange,FieldLength,IsMandatory,DefaultValue,ColumnName,IsCentrallyMaintained,EntityType,AD_Element_ID,AD_Process_Para_UU,IsEncrypted,IsAutocomplete) VALUES (200294,0,0,'Y',TO_DATE('2020-06-19 10:36:10','YYYY-MM-DD HH24:MI:SS'),100,TO_DATE('2020-06-19 10:36:10','YYYY-MM-DD HH24:MI:SS'),100,'New Window','Defines if it creates a new window record or creates a new tab on an existing window',200118,10,20,'N',0,'N','Y','IsNewWindow','Y','D',203419,'64bce238-182c-4322-81dc-6f2d1eebabea','N','N')
;
-- Jun 19, 2020, 10:39:08 AM CEST
INSERT INTO AD_Process_Para (AD_Process_Para_ID,AD_Client_ID,AD_Org_ID,IsActive,Created,CreatedBy,Updated,UpdatedBy,Name,Description,Help,AD_Process_ID,SeqNo,AD_Reference_ID,AD_Reference_Value_ID,IsRange,FieldLength,IsMandatory,DefaultValue,ColumnName,IsCentrallyMaintained,EntityType,AD_Element_ID,ReadOnlyLogic,DisplayLogic,AD_Process_Para_UU,IsEncrypted,MandatoryLogic,IsAutocomplete) VALUES (200295,0,0,'Y',TO_DATE('2020-06-19 10:39:07','YYYY-MM-DD HH24:MI:SS'),100,TO_DATE('2020-06-19 10:39:07','YYYY-MM-DD HH24:MI:SS'),100,'WindowType','Type or classification of a Window','The Window Type indicates the type of window being defined (Maintain, Transaction or Query)',200118,20,17,108,'N',0,'N','M','WindowType','Y','D',631,NULL,'@IsNewWindow@=''Y''','3ed90248-006a-4679-80a4-d8868f9787f2','N','@IsNewWindow@=''Y''','N')
;
-- Jun 19, 2020, 10:40:38 AM CEST
INSERT INTO AD_Process_Para (AD_Process_Para_ID,AD_Client_ID,AD_Org_ID,IsActive,Created,CreatedBy,Updated,UpdatedBy,Name,Description,Help,AD_Process_ID,SeqNo,AD_Reference_ID,IsRange,FieldLength,IsMandatory,ColumnName,IsCentrallyMaintained,EntityType,AD_Element_ID,DisplayLogic,AD_Process_Para_UU,IsEncrypted,IsAutocomplete) VALUES (200296,0,0,'Y',TO_DATE('2020-06-19 10:40:37','YYYY-MM-DD HH24:MI:SS'),100,TO_DATE('2020-06-19 10:40:37','YYYY-MM-DD HH24:MI:SS'),100,'Sales Transaction','This is a Sales Transaction','The Sales Transaction checkbox indicates if this item is a Sales Transaction.',200118,30,20,'N',1,'N','IsSOTrx','Y','D',1106,'@IsNewWindow@=''Y''','6f0465a6-25c0-44ca-a7c9-7f4f775e8528','N','N')
;
-- Jun 19, 2020, 10:40:44 AM CEST
UPDATE AD_Process_Para SET FieldLength=1,Updated=TO_DATE('2020-06-19 10:40:44','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Process_Para_ID=200295
;
-- Jun 19, 2020, 10:40:52 AM CEST
UPDATE AD_Process_Para SET FieldLength=1,Updated=TO_DATE('2020-06-19 10:40:52','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Process_Para_ID=200294
;
-- Jun 19, 2020, 10:42:38 AM CEST
INSERT INTO AD_Element (AD_Element_ID,AD_Client_ID,AD_Org_ID,IsActive,Created,CreatedBy,Updated,UpdatedBy,ColumnName,Name,Description,PrintName,EntityType,AD_Element_UU) VALUES (203420,0,0,'Y',TO_DATE('2020-06-19 10:42:37','YYYY-MM-DD HH24:MI:SS'),100,TO_DATE('2020-06-19 10:42:37','YYYY-MM-DD HH24:MI:SS'),100,'IsCreateMenu','Create Menu','Defines if it creates a new menu record for the new window','Create Menu','D','2f32e14c-2f68-410e-bf59-100686864549')
;
-- Jun 19, 2020, 10:43:12 AM CEST
INSERT INTO AD_Process_Para (AD_Process_Para_ID,AD_Client_ID,AD_Org_ID,IsActive,Created,CreatedBy,Updated,UpdatedBy,Name,Description,AD_Process_ID,SeqNo,AD_Reference_ID,IsRange,FieldLength,IsMandatory,DefaultValue,ColumnName,IsCentrallyMaintained,EntityType,AD_Element_ID,DisplayLogic,AD_Process_Para_UU,IsEncrypted,IsAutocomplete) VALUES (200297,0,0,'Y',TO_DATE('2020-06-19 10:43:11','YYYY-MM-DD HH24:MI:SS'),100,TO_DATE('2020-06-19 10:43:11','YYYY-MM-DD HH24:MI:SS'),100,'Create Menu','Defines if it creates a new menu record for the new window',200118,40,20,'N',1,'N','N','IsCreateMenu','Y','D',203420,'@IsNewWindow@=''Y''','b69cca27-9d64-4ead-83ca-3b01cb3e0e65','N','N')
;
-- Jun 19, 2020, 10:44:27 AM CEST
INSERT INTO AD_Process_Para (AD_Process_Para_ID,AD_Client_ID,AD_Org_ID,IsActive,Created,CreatedBy,Updated,UpdatedBy,Name,Description,Help,AD_Process_ID,SeqNo,AD_Reference_ID,IsRange,FieldLength,IsMandatory,DefaultValue,ColumnName,IsCentrallyMaintained,EntityType,AD_Element_ID,DisplayLogic,AD_Process_Para_UU,IsEncrypted,MandatoryLogic,IsAutocomplete) VALUES (200298,0,0,'Y',TO_DATE('2020-06-19 10:44:26','YYYY-MM-DD HH24:MI:SS'),100,TO_DATE('2020-06-19 10:44:26','YYYY-MM-DD HH24:MI:SS'),100,'Window','Data entry or display window','The Window field identifies a unique Window in the system.',200118,50,19,'N',22,'N',NULL,'AD_Window_ID','Y','D',143,'@IsNewWindow@=''N''','555f1f56-c2d6-412f-9d81-bdb8ea7f0a70','N','@IsNewWindow@=''N''','N')
;
-- Jun 19, 2020, 10:45:31 AM CEST
INSERT INTO AD_Process_Para (AD_Process_Para_ID,AD_Client_ID,AD_Org_ID,IsActive,Created,CreatedBy,Updated,UpdatedBy,Name,Description,Help,AD_Process_ID,SeqNo,AD_Reference_ID,IsRange,FieldLength,IsMandatory,ValueMin,ColumnName,IsCentrallyMaintained,EntityType,AD_Element_ID,DisplayLogic,AD_Process_Para_UU,IsEncrypted,MandatoryLogic,IsAutocomplete) VALUES (200299,0,0,'Y',TO_DATE('2020-06-19 10:45:30','YYYY-MM-DD HH24:MI:SS'),100,TO_DATE('2020-06-19 10:45:30','YYYY-MM-DD HH24:MI:SS'),100,'Tab Level','Hierarchical Tab Level (0 = top)','Hierarchical level of the tab. If the level is 0, it is the top entity. Level 1 entries are dependent on level 0, etc.',200118,60,11,'N',22,'N','0','TabLevel','Y','D',1725,'@IsNewWindow@=''N''','a618adee-33fd-4b4d-9c8d-746e265da407','N','@IsNewWindow@=''N''','N')
;
-- Jun 19, 2020, 10:48:38 AM CEST
INSERT INTO AD_Element (AD_Element_ID,AD_Client_ID,AD_Org_ID,IsActive,Created,CreatedBy,Updated,UpdatedBy,ColumnName,Name,PrintName,EntityType,AD_Element_UU) VALUES (203422,0,0,'Y',TO_DATE('2020-06-19 10:48:38','YYYY-MM-DD HH24:MI:SS'),100,TO_DATE('2020-06-19 10:48:38','YYYY-MM-DD HH24:MI:SS'),100,'CreateWindowFromTable','Create Window From Table','Create Window From Table','D','486d22a4-faaa-4d2e-ba7a-0ba49c40c06b')
;
-- Jun 19, 2020, 10:49:02 AM CEST
INSERT INTO AD_Column (AD_Column_ID,Version,Name,AD_Table_ID,ColumnName,FieldLength,IsKey,IsParent,IsMandatory,IsTranslated,IsIdentifier,SeqNo,IsEncrypted,AD_Reference_ID,AD_Client_ID,AD_Org_ID,IsActive,Created,CreatedBy,Updated,UpdatedBy,AD_Element_ID,IsUpdateable,AD_Process_ID,IsSelectionColumn,EntityType,IsSyncDatabase,IsAlwaysUpdateable,IsAutocomplete,IsAllowLogging,AD_Column_UU,IsAllowCopy,IsToolbarButton,IsSecure,IsHtml) VALUES (214207,1,'Create Window From Table',100,'CreateWindowFromTable',1,'N','N','N','N','N',0,'N',28,0,0,'Y',TO_DATE('2020-06-19 10:49:01','YYYY-MM-DD HH24:MI:SS'),100,TO_DATE('2020-06-19 10:49:01','YYYY-MM-DD HH24:MI:SS'),100,203422,'Y',200118,'N','D','N','N','N','Y','a68ccf9f-3997-4dab-a7d2-65a17f64d00c','Y','Y','N','N')
;
-- Jun 19, 2020, 10:49:07 AM CEST
ALTER TABLE AD_Table ADD CreateWindowFromTable CHAR(1) DEFAULT NULL
;
-- Jun 19, 2020, 10:51:02 AM CEST
INSERT INTO AD_Field (AD_Field_ID,Name,AD_Tab_ID,AD_Column_ID,IsDisplayed,DisplayLength,SeqNo,IsSameLine,IsHeading,IsFieldOnly,IsEncrypted,AD_Client_ID,AD_Org_ID,IsActive,Created,CreatedBy,Updated,UpdatedBy,IsReadOnly,IsCentrallyMaintained,EntityType,AD_Field_UU,IsDisplayedGrid,SeqNoGrid,XPosition,ColumnSpan,NumLines,IsQuickEntry,IsDefaultFocus,IsAdvancedField,IsQuickForm) VALUES (206414,'Create Window From Table',100,214207,'Y',1,230,'N','N','N','N',0,0,'Y',TO_DATE('2020-06-19 10:51:00','YYYY-MM-DD HH24:MI:SS'),100,TO_DATE('2020-06-19 10:51:00','YYYY-MM-DD HH24:MI:SS'),100,'N','Y','D','083abcc3-842b-498d-a228-514d9d458136','Y',160,2,2,1,'N','N','N','N')
;
-- Jun 19, 2020, 11:09:59 AM CEST
INSERT INTO AD_Message (MsgType,MsgText,AD_Client_ID,AD_Org_ID,IsActive,Created,CreatedBy,Updated,UpdatedBy,AD_Message_ID,Value,EntityType,AD_Message_UU) VALUES ('E','The table is not valid to create a new window, please verify that it has these columns: AD_Client_ID, AD_Org_ID, Created, CreatedBy, IsActive, Updated, UpdatedBy.',0,0,'Y',TO_DATE('2020-06-19 11:09:57','YYYY-MM-DD HH24:MI:SS'),100,TO_DATE('2020-06-19 11:09:57','YYYY-MM-DD HH24:MI:SS'),100,200615,'NewWindowNoValid','D','2bc73265-448f-4102-95f8-da94484e286f')
;
-- Jun 19, 2020, 11:49:59 AM CEST
INSERT INTO AD_Message (MsgType,MsgText,AD_Client_ID,AD_Org_ID,IsActive,Created,CreatedBy,Updated,UpdatedBy,AD_Message_ID,Value,EntityType,AD_Message_UU) VALUES ('E','Transaction windows require to have a Processed column. Please create the column and try again.',0,0,'Y',TO_DATE('2020-06-19 11:49:59','YYYY-MM-DD HH24:MI:SS'),100,TO_DATE('2020-06-19 11:49:59','YYYY-MM-DD HH24:MI:SS'),100,200616,'TrxWindowMandatoryProcessed','D','eb358a84-5395-4ee8-9ad6-5c532a2dd6a8')
;
-- Jun 22, 2020, 2:23:37 PM CEST
UPDATE AD_Process_Para SET DefaultValue=NULL,Updated=TO_DATE('2020-06-22 14:23:37','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Process_Para_ID=200076
;
-- Jun 24, 2020, 1:25:07 PM CEST
INSERT INTO AD_Message (MsgType,MsgText,AD_Client_ID,AD_Org_ID,IsActive,Created,CreatedBy,Updated,UpdatedBy,AD_Message_ID,Value,EntityType,AD_Message_UU) VALUES ('E','There is already a window with the name {0}',0,0,'Y',TO_DATE('2020-06-24 13:25:07','YYYY-MM-DD HH24:MI:SS'),100,TO_DATE('2020-06-24 13:25:07','YYYY-MM-DD HH24:MI:SS'),100,200617,'DuplicatedWindowName','D','12dbf77d-06a0-4300-92e0-ce0c2f1cdedb')
;
-- Jun 24, 2020, 1:30:43 PM CEST
INSERT INTO AD_Message (MsgType,MsgText,AD_Client_ID,AD_Org_ID,IsActive,Created,CreatedBy,Updated,UpdatedBy,AD_Message_ID,Value,EntityType,AD_Message_UU) VALUES ('E','No column is defined as Parent Link, therefore, the table cannot be a detail tab.',0,0,'Y',TO_DATE('2020-06-24 13:30:42','YYYY-MM-DD HH24:MI:SS'),100,TO_DATE('2020-06-24 13:30:42','YYYY-MM-DD HH24:MI:SS'),100,200618,'NoParentLink','D','5383b8b1-9434-4148-8ce0-7c901f9e5507')
;
-- Jun 24, 2020, 1:40:00 PM CEST
INSERT INTO AD_Message (MsgType,MsgText,AD_Client_ID,AD_Org_ID,IsActive,Created,CreatedBy,Updated,UpdatedBy,AD_Message_ID,Value,EntityType,AD_Message_UU) VALUES ('E','The maximum tab level for this window can be {0}.',0,0,'Y',TO_DATE('2020-06-24 13:40:00','YYYY-MM-DD HH24:MI:SS'),100,TO_DATE('2020-06-24 13:40:00','YYYY-MM-DD HH24:MI:SS'),100,200619,'MaxTabLevel','D','5ceed3b5-080a-4eab-b408-7f4eb2744624')
;
SELECT register_migration_script('202006191355_IDEMPIERE-1026.sql') FROM dual
;

View File

@ -0,0 +1,91 @@
-- IDEMPIERE-1026 Button on table to create automatically the window
-- Jun 19, 2020, 10:31:17 AM CEST
INSERT INTO AD_Process (AD_Process_ID,AD_Client_ID,AD_Org_ID,IsActive,Created,CreatedBy,Updated,UpdatedBy,Name,Description,Help,IsReport,Value,IsDirectPrint,Classname,AccessLevel,EntityType,Statistic_Count,Statistic_Seconds,IsBetaFunctionality,IsServerProcess,ShowHelp,CopyFromProcess,AD_Process_UU,AllowMultipleExecution) VALUES (200118,0,0,'Y',TO_TIMESTAMP('2020-06-19 10:31:16','YYYY-MM-DD HH24:MI:SS'),100,TO_TIMESTAMP('2020-06-19 10:31:16','YYYY-MM-DD HH24:MI:SS'),100,'Create Window, Tab & Field from Table','Create Window, Tab & Field record of the Table','This process will take the table definition and create the Window/Tab and field record with these options:<br>
New Window: if selected the process will create a new Window record. Otherwise, the process will create a new tab and add it to the selected window.<br>
Create Menu: if selected the process creates the menu record for the new window.','N','AD_Table_CreateWindow','N','org.compiere.process.CreateWindowFromTable','4','D',0,0,'N','N','Y','N','b1753358-c7dd-4387-ab99-355d081a5de2','P')
;
-- Jun 19, 2020, 10:35:37 AM CEST
INSERT INTO AD_Element (AD_Element_ID,AD_Client_ID,AD_Org_ID,IsActive,Created,CreatedBy,Updated,UpdatedBy,ColumnName,Name,Description,PrintName,EntityType,AD_Element_UU) VALUES (203419,0,0,'Y',TO_TIMESTAMP('2020-06-19 10:35:36','YYYY-MM-DD HH24:MI:SS'),100,TO_TIMESTAMP('2020-06-19 10:35:36','YYYY-MM-DD HH24:MI:SS'),100,'IsNewWindow','New Window','Defines if it creates a new window record or creates a new tab on an existing window','New Window','D','27a201ff-ce4c-4c82-a218-201e84c621cd')
;
-- Jun 19, 2020, 10:36:10 AM CEST
INSERT INTO AD_Process_Para (AD_Process_Para_ID,AD_Client_ID,AD_Org_ID,IsActive,Created,CreatedBy,Updated,UpdatedBy,Name,Description,AD_Process_ID,SeqNo,AD_Reference_ID,IsRange,FieldLength,IsMandatory,DefaultValue,ColumnName,IsCentrallyMaintained,EntityType,AD_Element_ID,AD_Process_Para_UU,IsEncrypted,IsAutocomplete) VALUES (200294,0,0,'Y',TO_TIMESTAMP('2020-06-19 10:36:10','YYYY-MM-DD HH24:MI:SS'),100,TO_TIMESTAMP('2020-06-19 10:36:10','YYYY-MM-DD HH24:MI:SS'),100,'New Window','Defines if it creates a new window record or creates a new tab on an existing window',200118,10,20,'N',0,'N','Y','IsNewWindow','Y','D',203419,'64bce238-182c-4322-81dc-6f2d1eebabea','N','N')
;
-- Jun 19, 2020, 10:39:08 AM CEST
INSERT INTO AD_Process_Para (AD_Process_Para_ID,AD_Client_ID,AD_Org_ID,IsActive,Created,CreatedBy,Updated,UpdatedBy,Name,Description,Help,AD_Process_ID,SeqNo,AD_Reference_ID,AD_Reference_Value_ID,IsRange,FieldLength,IsMandatory,DefaultValue,ColumnName,IsCentrallyMaintained,EntityType,AD_Element_ID,ReadOnlyLogic,DisplayLogic,AD_Process_Para_UU,IsEncrypted,MandatoryLogic,IsAutocomplete) VALUES (200295,0,0,'Y',TO_TIMESTAMP('2020-06-19 10:39:07','YYYY-MM-DD HH24:MI:SS'),100,TO_TIMESTAMP('2020-06-19 10:39:07','YYYY-MM-DD HH24:MI:SS'),100,'WindowType','Type or classification of a Window','The Window Type indicates the type of window being defined (Maintain, Transaction or Query)',200118,20,17,108,'N',0,'N','M','WindowType','Y','D',631,NULL,'@IsNewWindow@=''Y''','3ed90248-006a-4679-80a4-d8868f9787f2','N','@IsNewWindow@=''Y''','N')
;
-- Jun 19, 2020, 10:40:38 AM CEST
INSERT INTO AD_Process_Para (AD_Process_Para_ID,AD_Client_ID,AD_Org_ID,IsActive,Created,CreatedBy,Updated,UpdatedBy,Name,Description,Help,AD_Process_ID,SeqNo,AD_Reference_ID,IsRange,FieldLength,IsMandatory,ColumnName,IsCentrallyMaintained,EntityType,AD_Element_ID,DisplayLogic,AD_Process_Para_UU,IsEncrypted,IsAutocomplete) VALUES (200296,0,0,'Y',TO_TIMESTAMP('2020-06-19 10:40:37','YYYY-MM-DD HH24:MI:SS'),100,TO_TIMESTAMP('2020-06-19 10:40:37','YYYY-MM-DD HH24:MI:SS'),100,'Sales Transaction','This is a Sales Transaction','The Sales Transaction checkbox indicates if this item is a Sales Transaction.',200118,30,20,'N',1,'N','IsSOTrx','Y','D',1106,'@IsNewWindow@=''Y''','6f0465a6-25c0-44ca-a7c9-7f4f775e8528','N','N')
;
-- Jun 19, 2020, 10:40:44 AM CEST
UPDATE AD_Process_Para SET FieldLength=1,Updated=TO_TIMESTAMP('2020-06-19 10:40:44','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Process_Para_ID=200295
;
-- Jun 19, 2020, 10:40:52 AM CEST
UPDATE AD_Process_Para SET FieldLength=1,Updated=TO_TIMESTAMP('2020-06-19 10:40:52','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Process_Para_ID=200294
;
-- Jun 19, 2020, 10:42:38 AM CEST
INSERT INTO AD_Element (AD_Element_ID,AD_Client_ID,AD_Org_ID,IsActive,Created,CreatedBy,Updated,UpdatedBy,ColumnName,Name,Description,PrintName,EntityType,AD_Element_UU) VALUES (203420,0,0,'Y',TO_TIMESTAMP('2020-06-19 10:42:37','YYYY-MM-DD HH24:MI:SS'),100,TO_TIMESTAMP('2020-06-19 10:42:37','YYYY-MM-DD HH24:MI:SS'),100,'IsCreateMenu','Create Menu','Defines if it creates a new menu record for the new window','Create Menu','D','2f32e14c-2f68-410e-bf59-100686864549')
;
-- Jun 19, 2020, 10:43:12 AM CEST
INSERT INTO AD_Process_Para (AD_Process_Para_ID,AD_Client_ID,AD_Org_ID,IsActive,Created,CreatedBy,Updated,UpdatedBy,Name,Description,AD_Process_ID,SeqNo,AD_Reference_ID,IsRange,FieldLength,IsMandatory,DefaultValue,ColumnName,IsCentrallyMaintained,EntityType,AD_Element_ID,DisplayLogic,AD_Process_Para_UU,IsEncrypted,IsAutocomplete) VALUES (200297,0,0,'Y',TO_TIMESTAMP('2020-06-19 10:43:11','YYYY-MM-DD HH24:MI:SS'),100,TO_TIMESTAMP('2020-06-19 10:43:11','YYYY-MM-DD HH24:MI:SS'),100,'Create Menu','Defines if it creates a new menu record for the new window',200118,40,20,'N',1,'N','N','IsCreateMenu','Y','D',203420,'@IsNewWindow@=''Y''','b69cca27-9d64-4ead-83ca-3b01cb3e0e65','N','N')
;
-- Jun 19, 2020, 10:44:27 AM CEST
INSERT INTO AD_Process_Para (AD_Process_Para_ID,AD_Client_ID,AD_Org_ID,IsActive,Created,CreatedBy,Updated,UpdatedBy,Name,Description,Help,AD_Process_ID,SeqNo,AD_Reference_ID,IsRange,FieldLength,IsMandatory,DefaultValue,ColumnName,IsCentrallyMaintained,EntityType,AD_Element_ID,DisplayLogic,AD_Process_Para_UU,IsEncrypted,MandatoryLogic,IsAutocomplete) VALUES (200298,0,0,'Y',TO_TIMESTAMP('2020-06-19 10:44:26','YYYY-MM-DD HH24:MI:SS'),100,TO_TIMESTAMP('2020-06-19 10:44:26','YYYY-MM-DD HH24:MI:SS'),100,'Window','Data entry or display window','The Window field identifies a unique Window in the system.',200118,50,19,'N',22,'N',NULL,'AD_Window_ID','Y','D',143,'@IsNewWindow@=''N''','555f1f56-c2d6-412f-9d81-bdb8ea7f0a70','N','@IsNewWindow@=''N''','N')
;
-- Jun 19, 2020, 10:45:31 AM CEST
INSERT INTO AD_Process_Para (AD_Process_Para_ID,AD_Client_ID,AD_Org_ID,IsActive,Created,CreatedBy,Updated,UpdatedBy,Name,Description,Help,AD_Process_ID,SeqNo,AD_Reference_ID,IsRange,FieldLength,IsMandatory,ValueMin,ColumnName,IsCentrallyMaintained,EntityType,AD_Element_ID,DisplayLogic,AD_Process_Para_UU,IsEncrypted,MandatoryLogic,IsAutocomplete) VALUES (200299,0,0,'Y',TO_TIMESTAMP('2020-06-19 10:45:30','YYYY-MM-DD HH24:MI:SS'),100,TO_TIMESTAMP('2020-06-19 10:45:30','YYYY-MM-DD HH24:MI:SS'),100,'Tab Level','Hierarchical Tab Level (0 = top)','Hierarchical level of the tab. If the level is 0, it is the top entity. Level 1 entries are dependent on level 0, etc.',200118,60,11,'N',22,'N','0','TabLevel','Y','D',1725,'@IsNewWindow@=''N''','a618adee-33fd-4b4d-9c8d-746e265da407','N','@IsNewWindow@=''N''','N')
;
-- Jun 19, 2020, 10:48:38 AM CEST
INSERT INTO AD_Element (AD_Element_ID,AD_Client_ID,AD_Org_ID,IsActive,Created,CreatedBy,Updated,UpdatedBy,ColumnName,Name,PrintName,EntityType,AD_Element_UU) VALUES (203422,0,0,'Y',TO_TIMESTAMP('2020-06-19 10:48:38','YYYY-MM-DD HH24:MI:SS'),100,TO_TIMESTAMP('2020-06-19 10:48:38','YYYY-MM-DD HH24:MI:SS'),100,'CreateWindowFromTable','Create Window From Table','Create Window From Table','D','486d22a4-faaa-4d2e-ba7a-0ba49c40c06b')
;
-- Jun 19, 2020, 10:49:02 AM CEST
INSERT INTO AD_Column (AD_Column_ID,Version,Name,AD_Table_ID,ColumnName,FieldLength,IsKey,IsParent,IsMandatory,IsTranslated,IsIdentifier,SeqNo,IsEncrypted,AD_Reference_ID,AD_Client_ID,AD_Org_ID,IsActive,Created,CreatedBy,Updated,UpdatedBy,AD_Element_ID,IsUpdateable,AD_Process_ID,IsSelectionColumn,EntityType,IsSyncDatabase,IsAlwaysUpdateable,IsAutocomplete,IsAllowLogging,AD_Column_UU,IsAllowCopy,IsToolbarButton,IsSecure,IsHtml) VALUES (214207,1,'Create Window From Table',100,'CreateWindowFromTable',1,'N','N','N','N','N',0,'N',28,0,0,'Y',TO_TIMESTAMP('2020-06-19 10:49:01','YYYY-MM-DD HH24:MI:SS'),100,TO_TIMESTAMP('2020-06-19 10:49:01','YYYY-MM-DD HH24:MI:SS'),100,203422,'Y',200118,'N','D','N','N','N','Y','a68ccf9f-3997-4dab-a7d2-65a17f64d00c','Y','Y','N','N')
;
-- Jun 19, 2020, 10:49:07 AM CEST
ALTER TABLE AD_Table ADD COLUMN CreateWindowFromTable CHAR(1) DEFAULT NULL
;
-- Jun 19, 2020, 10:51:02 AM CEST
INSERT INTO AD_Field (AD_Field_ID,Name,AD_Tab_ID,AD_Column_ID,IsDisplayed,DisplayLength,SeqNo,IsSameLine,IsHeading,IsFieldOnly,IsEncrypted,AD_Client_ID,AD_Org_ID,IsActive,Created,CreatedBy,Updated,UpdatedBy,IsReadOnly,IsCentrallyMaintained,EntityType,AD_Field_UU,IsDisplayedGrid,SeqNoGrid,XPosition,ColumnSpan,NumLines,IsQuickEntry,IsDefaultFocus,IsAdvancedField,IsQuickForm) VALUES (206414,'Create Window From Table',100,214207,'Y',1,230,'N','N','N','N',0,0,'Y',TO_TIMESTAMP('2020-06-19 10:51:00','YYYY-MM-DD HH24:MI:SS'),100,TO_TIMESTAMP('2020-06-19 10:51:00','YYYY-MM-DD HH24:MI:SS'),100,'N','Y','D','083abcc3-842b-498d-a228-514d9d458136','Y',160,2,2,1,'N','N','N','N')
;
-- Jun 19, 2020, 11:09:59 AM CEST
INSERT INTO AD_Message (MsgType,MsgText,AD_Client_ID,AD_Org_ID,IsActive,Created,CreatedBy,Updated,UpdatedBy,AD_Message_ID,Value,EntityType,AD_Message_UU) VALUES ('E','The table is not valid to create a new window, please verify that it has these columns: AD_Client_ID, AD_Org_ID, Created, CreatedBy, IsActive, Updated, UpdatedBy.',0,0,'Y',TO_TIMESTAMP('2020-06-19 11:09:57','YYYY-MM-DD HH24:MI:SS'),100,TO_TIMESTAMP('2020-06-19 11:09:57','YYYY-MM-DD HH24:MI:SS'),100,200615,'NewWindowNoValid','D','2bc73265-448f-4102-95f8-da94484e286f')
;
-- Jun 19, 2020, 11:49:59 AM CEST
INSERT INTO AD_Message (MsgType,MsgText,AD_Client_ID,AD_Org_ID,IsActive,Created,CreatedBy,Updated,UpdatedBy,AD_Message_ID,Value,EntityType,AD_Message_UU) VALUES ('E','Transaction windows require to have a Processed column. Please create the column and try again.',0,0,'Y',TO_TIMESTAMP('2020-06-19 11:49:59','YYYY-MM-DD HH24:MI:SS'),100,TO_TIMESTAMP('2020-06-19 11:49:59','YYYY-MM-DD HH24:MI:SS'),100,200616,'TrxWindowMandatoryProcessed','D','eb358a84-5395-4ee8-9ad6-5c532a2dd6a8')
;
-- Jun 22, 2020, 2:23:37 PM CEST
UPDATE AD_Process_Para SET DefaultValue=NULL,Updated=TO_TIMESTAMP('2020-06-22 14:23:37','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Process_Para_ID=200076
;
-- Jun 24, 2020, 1:25:07 PM CEST
INSERT INTO AD_Message (MsgType,MsgText,AD_Client_ID,AD_Org_ID,IsActive,Created,CreatedBy,Updated,UpdatedBy,AD_Message_ID,Value,EntityType,AD_Message_UU) VALUES ('E','There is already a window with the name {0}',0,0,'Y',TO_TIMESTAMP('2020-06-24 13:25:07','YYYY-MM-DD HH24:MI:SS'),100,TO_TIMESTAMP('2020-06-24 13:25:07','YYYY-MM-DD HH24:MI:SS'),100,200617,'DuplicatedWindowName','D','12dbf77d-06a0-4300-92e0-ce0c2f1cdedb')
;
-- Jun 24, 2020, 1:30:43 PM CEST
INSERT INTO AD_Message (MsgType,MsgText,AD_Client_ID,AD_Org_ID,IsActive,Created,CreatedBy,Updated,UpdatedBy,AD_Message_ID,Value,EntityType,AD_Message_UU) VALUES ('E','No column is defined as Parent Link, therefore, the table cannot be a detail tab.',0,0,'Y',TO_TIMESTAMP('2020-06-24 13:30:42','YYYY-MM-DD HH24:MI:SS'),100,TO_TIMESTAMP('2020-06-24 13:30:42','YYYY-MM-DD HH24:MI:SS'),100,200618,'NoParentLink','D','5383b8b1-9434-4148-8ce0-7c901f9e5507')
;
-- Jun 24, 2020, 1:40:00 PM CEST
INSERT INTO AD_Message (MsgType,MsgText,AD_Client_ID,AD_Org_ID,IsActive,Created,CreatedBy,Updated,UpdatedBy,AD_Message_ID,Value,EntityType,AD_Message_UU) VALUES ('E','The maximum tab level for this window can be {0}.',0,0,'Y',TO_TIMESTAMP('2020-06-24 13:40:00','YYYY-MM-DD HH24:MI:SS'),100,TO_TIMESTAMP('2020-06-24 13:40:00','YYYY-MM-DD HH24:MI:SS'),100,200619,'MaxTabLevel','D','5ceed3b5-080a-4eab-b408-7f4eb2744624')
;
SELECT register_migration_script('202006191355_IDEMPIERE-1026.sql') FROM dual
;

View File

@ -0,0 +1,263 @@
/**********************************************************************
* This file is part of iDempiere ERP Open Source *
* http://www.idempiere.org *
* *
* Copyright (C) Contributors *
* *
* This program is free software; you can redistribute it and/or *
* modify it under the terms of the GNU General Public License *
* as published by the Free Software Foundation; either version 2 *
* of the License, or (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the Free Software *
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, *
* MA 02110-1301, USA. *
* *
* Contributors: *
* - BX Service GmbH *
* - Diego Ruiz *
**********************************************************************/
package org.compiere.process;
import java.util.logging.Level;
import org.adempiere.exceptions.AdempiereException;
import org.compiere.model.MColumn;
import org.compiere.model.MMenu;
import org.compiere.model.MPInstance;
import org.compiere.model.MTab;
import org.compiere.model.MTable;
import org.compiere.model.MWindow;
import org.compiere.model.SystemIDs;
import org.compiere.util.DB;
import org.compiere.util.Msg;
import org.compiere.util.Trx;
/**
* Create Menu - Window/tab & field from a table
*
* @author Diego Ruiz - BX Service GmbH
*/
public class CreateWindowFromTable extends SvrProcess
{
/** Table */
private int p_AD_Table_ID = 0;
/** Window Type */
private String p_WindowType = null;
/** Sales transaction */
private boolean p_IsSOTrx = false;
/** Is a New Window? */
private boolean p_isNewWindow = false;
/** AD_Window_ID */
private int p_AD_Window_ID = 0;
/** Tab Level */
private int p_TabLevel = 0;
/** Create Menu Record */
private boolean p_isCreateMenu = false;
/**
* Prepare - e.g., get Parameters.
*/
protected void prepare ()
{
ProcessInfoParameter[] para = getParameter();
for (int i = 0; i < para.length; i++)
{
String name = para[i].getParameterName();
if (para[i].getParameter() == null)
;
else if (name.equals("WindowType"))
p_WindowType = para[i].getParameterAsString();
else if (name.equals("IsSOTrx"))
p_IsSOTrx = para[i].getParameterAsBoolean();
else if (name.equals("IsNewWindow"))
p_isNewWindow = para[i].getParameterAsBoolean();
else if (name.equals("AD_Window_ID"))
p_AD_Window_ID = para[i].getParameterAsInt();
else if (name.equals("TabLevel"))
p_TabLevel = para[i].getParameterAsInt();
else if (name.equals("IsCreateMenu"))
p_isCreateMenu = para[i].getParameterAsBoolean();
else
log.log(Level.SEVERE, "Unknown Parameter: " + name);
}
p_AD_Table_ID = getRecord_ID();
} // prepare
/**
* Process
* @return info
* @throws Exception
*/
protected String doIt () throws Exception
{
if (p_AD_Table_ID == 0)
throw new AdempiereException("@NotFound@ @AD_Table_ID@ " + p_AD_Table_ID);
if (!p_isNewWindow && p_AD_Window_ID == 0)
throw new AdempiereException("@Mandatory@ @AD_Window_ID@");
if (log.isLoggable(Level.INFO))
log.info("Source AD_Table_ID=" + p_AD_Table_ID);
MTable table = new MTable(getCtx(), p_AD_Table_ID, get_TrxName());
if (table != null) {
String entityType = table.getEntityType();
if (!isTableValid(table))
throw new AdempiereException(Msg.getMsg(getCtx(), "NewWindowNoValid"));
MWindow window;
if (p_isNewWindow) {
if (MWindow.WINDOWTYPE_Transaction.equals(p_WindowType) &&
table.getColumnIndex("Processed") <= 0)
throw new AdempiereException(Msg.getMsg(getCtx(), "TrxWindowMandatoryProcessed"));
int i = DB.getSQLValue(get_TrxName(), "SELECT 1 FROM AD_Window WHERE AD_Window.name = ?", table.getName());
if (i == 1)
throw new AdempiereException(Msg.getMsg(getCtx(), "DuplicatedWindowName", new Object[] {table.getName()}));
window = new MWindow(getCtx(), 0, get_TrxName());
window.setName(table.getName());
window.setIsSOTrx(p_IsSOTrx);
window.setWindowType(p_WindowType);
window.setEntityType(entityType);
window.saveEx();
addLog(window.getAD_Window_ID(), null, null, "@AD_Window_ID@: " + window.getName(),
window.get_Table_ID(), window.getAD_Window_ID());
} else {
//If no new window but a detail tab
if (p_TabLevel > 0) {
boolean hasParentLinkColumn = false;
for (MColumn column : table.getColumns(false)) {
if (column.isParent()) {
hasParentLinkColumn = true;
break;
}
}
if (!hasParentLinkColumn)
throw new AdempiereException(Msg.getMsg(getCtx(), "NoParentLink"));
}
window = new MWindow(getCtx(), p_AD_Window_ID, get_TrxName());
if (p_TabLevel > 1) {
int maxTabLevel = 0;
for (MTab tab : window.getTabs(false, get_TrxName())) {
if (tab.getTabLevel() > maxTabLevel) {
maxTabLevel = tab.getTabLevel();
}
}
if (maxTabLevel+1 < p_TabLevel)
throw new AdempiereException(Msg.getMsg(getCtx(), "MaxTabLevel", new Object[] {maxTabLevel+1}));
}
}
MTab tab = new MTab(window);
tab.setName(table.getName());
tab.setAD_Table_ID(p_AD_Table_ID);
tab.setTabLevel(p_TabLevel);
tab.setIsSingleRow(true); //Default
//Set order by
if (table.getColumnIndex("Value") > 0)
tab.setOrderByClause(table.getTableName() + ".Value");
else if (table.getColumnIndex("Name") > 0)
tab.setOrderByClause(table.getTableName() + ".Name");
else
tab.setOrderByClause(table.getTableName() + ".Created DESC");
tab.saveEx();
addLog(tab.getAD_Tab_ID(), null, null, "@AD_Tab_ID@: " + tab.getName(),
tab.get_Table_ID(), tab.getAD_Tab_ID());
//Create Fields
ProcessInfo processInfo = new ProcessInfo("", SystemIDs.PROCESS_AD_TAB_CREATEFIELDS, 0, tab.getAD_Tab_ID());
MPInstance instance = new MPInstance(getCtx(), SystemIDs.PROCESS_AD_TAB_CREATEFIELDS, 0);
instance.saveEx();
processInfo.setAD_PInstance_ID(instance.getAD_PInstance_ID());
TabCreateFields createFields = new TabCreateFields();
boolean success = createFields.startProcess(getCtx(), processInfo, Trx.get(get_TrxName(), false));
if (!success) {
StringBuilder msgout = new StringBuilder("Process=").append(processInfo.getTitle())
.append(" Called from=").append("CreateWindowFromTable")
.append(" Error=").append(processInfo.isError())
.append(" Summary=").append(processInfo.getSummary());
log.severe(msgout.toString());
throw new AdempiereException(processInfo.getSummary());
}
if (p_isCreateMenu) {
MMenu menu = new MMenu(getCtx(), 0, get_TrxName());
menu.setName(window.getName());
menu.setEntityType(entityType);
menu.setIsSOTrx(p_IsSOTrx);
menu.setAction(MMenu.ACTION_Window);
menu.setAD_Window_ID(window.getAD_Window_ID());
menu.saveEx();
addLog(menu.getAD_Menu_ID(), null, null, "@AD_Menu_ID@: " + menu.getName(),
menu.get_Table_ID(), menu.getAD_Menu_ID());
}
//If AD_Window_ID is empty in the Table record
if (table.getAD_Window_ID() <= 0)
table.setAD_Window_ID(window.getAD_Window_ID());
table.saveEx();
}
return "@OK@";
} // doIt
/**
*
* @param table Table to be verifies
* @return true if the table has all recommended columns
*/
public boolean isTableValid(MTable table) {
boolean hasIsActive = false;
boolean hasAD_Client_ID = false;
boolean hasAD_Org_ID = false;
boolean hasCreated = false;
boolean hasUpdated = false;
boolean hasCreatedBy = false;
boolean hasUpdatedBy = false;
for (MColumn column : table.getColumns(true)) {
if (column.getAD_Element_ID() == SystemIDs.ELEMENT_AD_CLIENT_ID)
hasAD_Client_ID = true;
else if (column.getAD_Element_ID() == SystemIDs.ELEMENT_AD_ORG_ID)
hasAD_Org_ID = true;
else if (column.getAD_Element_ID() == SystemIDs.ELEMENT_CREATED)
hasCreated = true;
else if (column.getAD_Element_ID() == SystemIDs.ELEMENT_CREATEDBY)
hasCreatedBy = true;
else if (column.getAD_Element_ID() == SystemIDs.ELEMENT_ISACTIVE)
hasIsActive = true;
else if (column.getAD_Element_ID() == SystemIDs.ELEMENT_UPDATED)
hasUpdated = true;
else if (column.getAD_Element_ID() == SystemIDs.ELEMENT_UPDATEDBY)
hasUpdatedBy = true;
}
return hasIsActive && hasAD_Client_ID && hasAD_Org_ID && hasCreated &&
hasUpdated && hasCreatedBy && hasUpdatedBy;
} // isTableValid
}

View File

@ -105,6 +105,7 @@ public class TabCreateFields extends SvrProcess
sql += "ORDER BY CASE "
+ " WHEN c.ColumnName = 'AD_Client_ID' THEN -100 "
+ " WHEN c.ColumnName = 'AD_Org_ID' THEN -90 "
+ " WHEN c.IsParent = 'Y' THEN -85 "
+ " WHEN c.ColumnName = 'Value' THEN -80 "
+ " WHEN c.ColumnName = 'Name' THEN -70 "
+ " WHEN c.ColumnName = 'Description' THEN -60 "

View File

@ -44,6 +44,14 @@ public class SystemIDs
public final static int COUNTRY_US = 100;
public final static int COUNTRY_JAPAN = 216;
public final static int ELEMENT_AD_CLIENT_ID = 102;
public final static int ELEMENT_AD_ORG_ID = 113;
public final static int ELEMENT_CREATED = 245;
public final static int ELEMENT_CREATEDBY = 246;
public final static int ELEMENT_UPDATED = 607;
public final static int ELEMENT_UPDATEDBY = 608;
public final static int ELEMENT_ISACTIVE = 348;
public final static int ENTITYTYPE_ADEMPIERE = 20;
public final static int ENTITYTYPE_DICTIONARY = 10;
@ -73,6 +81,7 @@ public class SystemIDs
public final static int PROCESS_AD_CHANGELOG_UNDO = 306;
public final static int PROCESS_AD_CHANGELOG_REDO = 307;
public final static int PROCESS_AD_NATIVE_SEQUENCE_ENABLE = 53156;
public final static int PROCESS_AD_TAB_CREATEFIELDS = 174;
public final static int PROCESS_C_INVOICE_GENERATE = 119;
public final static int PROCESS_C_INVOICE_GENERATE_MANUAL = 134;
public final static int PROCESS_C_INVOICE_GENERATERMA_MANUAL = 52002;