src-db/database/model/triggers/AD_SYSTEM_INFO_TRG2.xml
author Victor Villar <victor.villar@openbravo.com>
Mon, 04 Nov 2013 17:57:05 +0100
changeset 21412 cbfed8a6d9a0
parent 16390 588bdc741142
child 21850 cf95ca28bb9b
permissions -rw-r--r--
Fixed issue 25074:the standard cost is taking
into account the wrong price list for consumed products
<?xml version="1.0"?>
  <database name="TRIGGER AD_SYSTEM_INFO_TRG2">
    <trigger name="AD_SYSTEM_INFO_TRG2" table="AD_SYSTEM_INFO" fires="after" insert="false" update="true" delete="false" foreach="row">
      <body><![CDATA[

/*************************************************************************
* The contents of this file are subject to the Openbravo  Public  License
* Version  1.1  (the  "License"),  being   the  Mozilla   Public  License
* Version 1.1  with a permitted attribution clause; you may not  use this
* file except in compliance with the License. You  may  obtain  a copy of
* the License at http://www.openbravo.com/legal/license.html
* Software distributed under the License  is  distributed  on  an "AS IS"
* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
* License for the specific  language  governing  rights  and  limitations
* under the License.
* The Original Code is Openbravo ERP.
* The Initial Developer of the Original Code is Openbravo SLU
* All portions are Copyright (C) 2008-2012 Openbravo SLU
* All Rights Reserved.
* Contributor(s):  ______________________________________.
************************************************************************/

exist NUMBER:= 0;
indTempName NVARCHAR2(50) := 'System Customization';
indTempPackage NVARCHAR2(50) := 'mySystem.CustomizationTemplate';
idCustomizationModule NVARCHAR2(50);
coreVersion NVARCHAR2(10);

    
BEGIN
    
    IF AD_isTriggerEnabled()='N' THEN RETURN;
    END IF;


  If :old.customization_Allowed='N' and :new.customization_Allowed='Y' then
  
    select count(*) into exist
    from AD_MODULE
    where TYPE = 'T'
    and ISINDEVELOPMENT = 'Y';
    
    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);
        
      -- 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);
    end if;
  end if;
  
  If (:old.customization_Allowed='Y' and :new.customization_Allowed='N') then
    delete from AD_MODULE
    where name = indTempName;
  end if;
 
  if :old.showForgeLogo='Y' and :new.showForgeLogo='N' then
    select count(*)
      into exist
      from ad_system
     where instance_Key is null;
     
     if exist != 0 then
       RAISE_APPLICATION_ERROR(-20000,'@ShowForgeLogoCommunity@');
     end if;
  end if;

END AD_SYSTEM_INFO_TRG2
]]></body>
    </trigger>
  </database>