Fixes issue 27317: When you add a new value to product
authorJavier Etxarri <javier.echarri@openbravo.com>
Thu, 14 Aug 2014 14:54:47 -0500
changeset 24259 30d537a20692
parent 24258 2d3dfb5d3eaf
child 24261 a5a296d4988d
Fixes issue 27317: When you add a new value to product
characteristic it adds with isactive='N' and it will be find to be configurable
src-db/database/model/triggers/M_CH_SUBSET_VALUE_TRG.xml
src-db/database/model/triggers/M_CH_VALUE_TRG.xml
src-db/database/sourcedata/AD_REF_LIST.xml
--- a/src-db/database/model/triggers/M_CH_SUBSET_VALUE_TRG.xml	Thu Aug 14 20:54:39 2014 +0200
+++ b/src-db/database/model/triggers/M_CH_SUBSET_VALUE_TRG.xml	Thu Aug 14 14:54:47 2014 -0500
@@ -14,17 +14,33 @@
 * under the License.
 * The Original Code is Openbravo ERP.
 * The Initial Developer of the Original Code is Openbravo SLU
-* All portions are Copyright (C) 2013 Openbravo SLU
+* All portions are Copyright (C) 2013-2014 Openbravo SLU
 * All Rights Reserved.
 * Contributor(s):  ______________________________________.
 ************************************************************************/
-  v_characteristic_id NVARCHAR2(32);
+  v_characteristic_id 	NVARCHAR2(32);
+  v_active 		VARCHAR2(32):='N';
+  v_exist	NUMBER:=0;
 BEGIN
   IF (AD_isTriggerEnabled()='N') THEN
     RETURN;
   END IF;
   -- Insert values in generic products using the subset
   IF (INSERTING) THEN
+
+    select count(*) into v_exist
+    from ad_preference
+    where ad_client_id=:new.ad_client_id
+    and property='IsActiveNewChValueProd';
+
+    IF (v_exist > 0) THEN
+      select value into v_active
+      from ad_preference
+      where ad_client_id=:new.ad_client_id
+	    and property='IsActiveNewChValueProd';
+    END IF;  
+
+
     SELECT m_characteristic_id INTO v_characteristic_id
     FROM m_ch_subset
     WHERE :new.m_ch_subset_id = m_ch_subset_id;
@@ -33,7 +49,7 @@
       created, createdby, updated, updatedby,
       m_product_ch_id, m_ch_value_id, skcode
     ) SELECT
-      get_uuid(), :new.ad_client_id, :new.ad_org_id, 'N',
+      get_uuid(), :new.ad_client_id, :new.ad_org_id, v_active,
       now(), :new.createdby, now(), :new.updatedby,
       pch.m_product_ch_id, :new.m_ch_value_id, :new.skcode
       FROM m_product_ch pch
--- a/src-db/database/model/triggers/M_CH_VALUE_TRG.xml	Thu Aug 14 20:54:39 2014 +0200
+++ b/src-db/database/model/triggers/M_CH_VALUE_TRG.xml	Thu Aug 14 14:54:47 2014 -0500
@@ -14,7 +14,7 @@
 * under the License.
 * The Original Code is Openbravo ERP.
 * The Initial Developer of the Original Code is Openbravo SLU
-* All portions are Copyright (C) 2013 Openbravo SLU
+* All portions are Copyright (C) 2013-2014 Openbravo SLU
 * All Rights Reserved.
 * Contributor(s):  ______________________________________.
 ************************************************************************/
@@ -23,6 +23,8 @@
   v_Parent_ID         VARCHAR2(32);
   v_NextNo            VARCHAR2(32);
   v_count             NUMBER;
+  v_active            VARCHAR2(32):='N';
+  v_exist NUMBER:=0;
 
 BEGIN
   IF (AD_isTriggerEnabled()='N') THEN
@@ -63,12 +65,25 @@
           END
       );
     END IF;
+
+    select count(*) into v_exist
+    from ad_preference
+    where ad_client_id=:new.ad_client_id
+    and property='IsActiveNewChValueProd';
+
+    IF (v_exist > 0) THEN
+      select value into v_active
+      from ad_preference
+      where ad_client_id=:new.ad_client_id
+      and property='IsActiveNewChValueProd';
+    END IF;  
+
     INSERT INTO m_product_ch_conf (
       m_product_ch_conf_id, ad_client_id, ad_org_id, isactive,
       created, createdby, updated, updatedby,
       m_product_ch_id, m_ch_value_id, skcode
     ) SELECT
-      get_uuid(), :new.ad_client_id, :new.ad_org_id, 'N',
+      get_uuid(), :new.ad_client_id, :new.ad_org_id, v_active,
       now(), :new.createdby, now(), :new.updatedby,
       pch.m_product_ch_id, :new.m_ch_value_id, :new.skcode
       FROM m_product_ch pch
--- a/src-db/database/sourcedata/AD_REF_LIST.xml	Thu Aug 14 20:54:39 2014 +0200
+++ b/src-db/database/sourcedata/AD_REF_LIST.xml	Thu Aug 14 14:54:47 2014 -0500
@@ -12536,6 +12536,17 @@
 <!--FBCE5CC9E77A43ED8ABBE27FC48F2C06-->  <AD_MODULE_ID><![CDATA[0]]></AD_MODULE_ID>
 <!--FBCE5CC9E77A43ED8ABBE27FC48F2C06--></AD_REF_LIST>
 
+<!--FD134D58B4A14BB1AA5F4870020E8CB5--><AD_REF_LIST>
+<!--FD134D58B4A14BB1AA5F4870020E8CB5-->  <AD_REF_LIST_ID><![CDATA[FD134D58B4A14BB1AA5F4870020E8CB5]]></AD_REF_LIST_ID>
+<!--FD134D58B4A14BB1AA5F4870020E8CB5-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
+<!--FD134D58B4A14BB1AA5F4870020E8CB5-->  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
+<!--FD134D58B4A14BB1AA5F4870020E8CB5-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
+<!--FD134D58B4A14BB1AA5F4870020E8CB5-->  <VALUE><![CDATA[IsActiveNewChValueProd]]></VALUE>
+<!--FD134D58B4A14BB1AA5F4870020E8CB5-->  <NAME><![CDATA[Active new chValue in Product]]></NAME>
+<!--FD134D58B4A14BB1AA5F4870020E8CB5-->  <AD_REFERENCE_ID><![CDATA[A26BA480E2014707B47257024C3CBFF7]]></AD_REFERENCE_ID>
+<!--FD134D58B4A14BB1AA5F4870020E8CB5-->  <AD_MODULE_ID><![CDATA[0]]></AD_MODULE_ID>
+<!--FD134D58B4A14BB1AA5F4870020E8CB5--></AD_REF_LIST>
+
 <!--FD374D3374054128A14530F1A71A72D8--><AD_REF_LIST>
 <!--FD374D3374054128A14530F1A71A72D8-->  <AD_REF_LIST_ID><![CDATA[FD374D3374054128A14530F1A71A72D8]]></AD_REF_LIST_ID>
 <!--FD374D3374054128A14530F1A71A72D8-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>