Fixes issue 25078: Unchecking Customization Allowed removes template
authorAugusto Mauch <augusto.mauch@openbravo.com>
Thu, 23 Jan 2014 14:10:06 +0100
changeset 21850 cf95ca28bb9b
parent 21849 b6f6c4710817
child 21851 8db997908be3
Fixes issue 25078: Unchecking Customization Allowed removes template

When the Customization Allowed flag is unchecked, instead of removing the System Customization template its In Development flag is set to false.
src-db/database/model/triggers/AD_SYSTEM_INFO_TRG2.xml
--- a/src-db/database/model/triggers/AD_SYSTEM_INFO_TRG2.xml	Thu Jan 23 12:30:29 2014 +0100
+++ b/src-db/database/model/triggers/AD_SYSTEM_INFO_TRG2.xml	Thu Jan 23 14:10:06 2014 +0100
@@ -21,6 +21,7 @@
 ************************************************************************/
 
 exist NUMBER:= 0;
+existDisabled NUMBER:= 0;
 indTempName NVARCHAR2(50) := 'System Customization';
 indTempPackage NVARCHAR2(50) := 'mySystem.CustomizationTemplate';
 idCustomizationModule NVARCHAR2(50);
@@ -43,44 +44,57 @@
     if (exist > 0) then
       RAISE_APPLICATION_ERROR(-20000,'@20631@');
     else
-      idCustomizationModule:=get_uuid();
-      Insert into AD_MODULE (
-        AD_MODULE_ID,AD_CLIENT_ID,AD_ORG_ID,ISACTIVE,CREATED,CREATEDBY,UPDATED,UPDATEDBY,
-        NAME,VERSION,DESCRIPTION,
-        HELP,
-        URL,TYPE,LICENSE,
-        ISINDEVELOPMENT,ISDEFAULT,SEQNO,JAVAPACKAGE,
-        LICENSETYPE,AUTHOR,STATUS,UPDATE_AVAILABLE,ISTRANSLATIONREQUIRED,AD_LANGUAGE,HASCHARTOFACCOUNTS,
-        ISTRANSLATIONMODULE,HASREFERENCEDATA,ISREGISTERED,UPDATEINFO,UPDATE_VER_ID) 
-      values (
-        to_char(idCustomizationModule),'0','0','Y',now(),'0',now(),'0',
-        to_char(indTempName),'1.0.0', to_char(indTempName) || ' is an autogenerated industry template to store all the customizations made to module core.',
-        to_char(indTempName) || ' is an autogenerated industry template to store all the customizations made to module core. Only one industry template can be active at the same time.',
-        null,'T','The Openbravo Public License Version 1.1 ("OBPL") consists of the Mozilla Public License Version 1.1, modified to be specific to Openbravo, with the Additional Terms in Exhibit B. The original Mozilla Public License 1.1 can be found at: http://www.mozilla.org/MPL/MPL-1.1.html',
-        'Y','N',null,to_char(indTempPackage),
-        'OtherOS',null,null,null,'Y','en_US','N',
-        'N','N',null,null,null);
+      select count(*) into existDisabled
+      from AD_MODULE
+      where TYPE = 'T'
+      and ISINDEVELOPMENT = 'N'
+      and NAME = indTempName;
+
+      if (existDisabled > 0) then
+        update AD_MODULE
+        set isindevelopment = 'Y'
+        where name = indTempName;
+      else
+        idCustomizationModule:=get_uuid();
+        Insert into AD_MODULE (
+          AD_MODULE_ID,AD_CLIENT_ID,AD_ORG_ID,ISACTIVE,CREATED,CREATEDBY,UPDATED,UPDATEDBY,
+          NAME,VERSION,DESCRIPTION,
+          HELP,
+          URL,TYPE,LICENSE,
+          ISINDEVELOPMENT,ISDEFAULT,SEQNO,JAVAPACKAGE,
+          LICENSETYPE,AUTHOR,STATUS,UPDATE_AVAILABLE,ISTRANSLATIONREQUIRED,AD_LANGUAGE,HASCHARTOFACCOUNTS,
+          ISTRANSLATIONMODULE,HASREFERENCEDATA,ISREGISTERED,UPDATEINFO,UPDATE_VER_ID)
+        values (
+          to_char(idCustomizationModule),'0','0','Y',now(),'0',now(),'0',
+          to_char(indTempName),'1.0.0', to_char(indTempName) || ' is an autogenerated industry template to store all the customizations made to module core.',
+          to_char(indTempName) || ' is an autogenerated industry template to store all the customizations made to module core. Only one industry template can be active at the same time.',
+          null,'T','The Openbravo Public License Version 1.1 ("OBPL") consists of the Mozilla Public License Version 1.1, modified to be specific to Openbravo, with the Additional Terms in Exhibit B. The original Mozilla Public License 1.1 can be found at: http://www.mozilla.org/MPL/MPL-1.1.html',
+          'Y','N',null,to_char(indTempPackage),
+          'OtherOS',null,null,null,'Y','en_US','N',
+          'N','N',null,null,null);
         
-      -- add dependency on the core module
-      select version into coreVersion 
-      from AD_MODULE 
-      where AD_MODULE_ID='0';
+        -- add dependency on the core module
+        select version into coreVersion
+        from AD_MODULE
+        where AD_MODULE_ID='0';
       
-      Insert into AD_MODULE_DEPENDENCY (
-         AD_MODULE_DEPENDENCY_ID, AD_CLIENT_ID, AD_ORG_ID, ISACTIVE, CREATED, CREATEDBY,
-         UPDATED, UPDATEDBY, AD_MODULE_ID, AD_DEPENDENT_MODULE_ID, 
-         STARTVERSION, ENDVERSION, ISINCLUDED, DEPENDANT_MODULE_NAME,
-         DEPENDENCY_ENFORCEMENT, USER_EDITABLE_ENFORCEMENT, INSTANCE_ENFORCEMENT)
-      values(
-         get_uuid(),'0','0', 'Y', now(), '0',
-         now(),'0', to_char(idCustomizationModule), '0', 
-         to_char(coreVersion), null, 'N', 'Will be overwritten by insert/update trigger',
-         'MAJOR', 'N', null);
+        Insert into AD_MODULE_DEPENDENCY (
+           AD_MODULE_DEPENDENCY_ID, AD_CLIENT_ID, AD_ORG_ID, ISACTIVE, CREATED, CREATEDBY,
+           UPDATED, UPDATEDBY, AD_MODULE_ID, AD_DEPENDENT_MODULE_ID,
+           STARTVERSION, ENDVERSION, ISINCLUDED, DEPENDANT_MODULE_NAME,
+           DEPENDENCY_ENFORCEMENT, USER_EDITABLE_ENFORCEMENT, INSTANCE_ENFORCEMENT)
+        values(
+           get_uuid(),'0','0', 'Y', now(), '0',
+           now(),'0', to_char(idCustomizationModule), '0',
+           to_char(coreVersion), null, 'N', 'Will be overwritten by insert/update trigger',
+           'MAJOR', 'N', null);
+      end if;
     end if;
   end if;
   
   If (:old.customization_Allowed='Y' and :new.customization_Allowed='N') then
-    delete from AD_MODULE
+    update AD_MODULE
+    set isindevelopment = 'N'
     where name = indTempName;
   end if;