[Characteristics]Implement Characteristic Values tree.
authorGorka Ion Damián <gorkaion.damian@openbravo.com>
Fri, 01 Mar 2013 11:14:11 +0100
changeset 20862 289600223835
parent 20861 80cf9faa3b8c
child 20863 14faf6af5691
[Characteristics]Implement Characteristic Values tree.
src-db/database/model/tables/M_CHARACTERISTIC.xml
src-db/database/model/triggers/M_CHARACTERISTIC_TRG.xml
src-db/database/model/triggers/M_CH_VALUE_TRG.xml
src-db/database/sourcedata/AD_COLUMN.xml
src-db/database/sourcedata/AD_FIELD.xml
src-db/database/sourcedata/AD_REF_LIST.xml
src-db/database/sourcedata/AD_TAB.xml
src-db/database/sourcedata/AD_VAL_RULE.xml
src/org/openbravo/erpCommon/businessUtility/InitialClientSetup.java
src/org/openbravo/erpCommon/utility/WindowTreeChecks.java
src/org/openbravo/erpCommon/utility/WindowTreeUtility.java
src/org/openbravo/erpCommon/utility/WindowTree_data.xsql
--- a/src-db/database/model/tables/M_CHARACTERISTIC.xml	Thu Feb 28 18:36:35 2013 +0100
+++ b/src-db/database/model/tables/M_CHARACTERISTIC.xml	Fri Mar 01 11:14:11 2013 +0100
@@ -45,12 +45,19 @@
         <default/>
         <onCreateDefault/>
       </column>
+      <column name="AD_TREE_ID" primaryKey="false" required="true" type="VARCHAR" size="32" autoIncrement="false">
+        <default/>
+        <onCreateDefault/>
+      </column>
       <foreign-key foreignTable="AD_CLIENT" name="M_CHARACTERISTIC_AD_CLIENT">
         <reference local="AD_CLIENT_ID" foreign="AD_CLIENT_ID"/>
       </foreign-key>
       <foreign-key foreignTable="AD_ORG" name="M_CHARACTERISTIC_AD_ORG">
         <reference local="AD_ORG_ID" foreign="AD_ORG_ID"/>
       </foreign-key>
+      <foreign-key foreignTable="AD_TREE" name="M_PRODUCT_TREE">
+        <reference local="AD_TREE_ID" foreign="AD_TREE_ID"/>
+      </foreign-key>
       <check name="M_CHARACTERISTIC_ISACTIVE"><![CDATA[ISACTIVE IN ('Y', 'N')]]></check>
     </table>
   </database>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src-db/database/model/triggers/M_CHARACTERISTIC_TRG.xml	Fri Mar 01 11:14:11 2013 +0100
@@ -0,0 +1,60 @@
+<?xml version="1.0"?>
+  <database name="TRIGGER M_CHARACTERISTIC_TRG">
+    <trigger name="M_CHARACTERISTIC_TRG" table="M_CHARACTERISTIC" fires="before" insert="true" update="false" 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) 2013 Openbravo SLU
+* All Rights Reserved.
+* Contributor(s):  ______________________________________.
+************************************************************************/
+
+  v_tree_id           VARCHAR2(32);
+  v_count             NUMBER;
+
+BEGIN
+  IF (AD_isTriggerEnabled()='N') THEN
+    RETURN;
+  END IF;
+
+  IF INSERTING THEN
+    IF (:NEW.ad_tree_id IS NULL) THEN
+      SELECT count(*), max(ad_tree_id)
+        INTO v_count, v_tree_id
+      FROM ad_tree
+      WHERE treetype = 'CH'
+        AND isactive = 'Y'
+        AND ad_client_id = :NEW.ad_client_id
+        AND ad_org_isinnaturaltree(ad_org_id, :NEW.ad_org_id, ad_client_id) = 'Y';
+      IF (v_count > 0) THEN
+        :NEW.ad_tree_id := v_tree_id;
+      ELSE
+        -- Create new tree
+        v_tree_id := get_uuid();
+        INSERT INTO ad_tree (
+            ad_tree_id, ad_client_id, ad_org_id, isactive,
+            created, createdby, updated, updatedby,
+            name, description, treetype, isallnodes
+        ) VALUES (
+            v_tree_id, :NEW.ad_client_id, :NEW.ad_org_id, :NEW.isactive,
+            now(), :NEW.createdby, now(), :NEW.updatedby,
+            'Product Characteristic tree', null, 'CH', 'Y'
+        );
+        :NEW.ad_tree_id := v_tree_id;
+      END IF;
+    END IF;
+  END IF;
+END M_CHARACTERISTIC_TRG
+]]></body>
+    </trigger>
+  </database>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src-db/database/model/triggers/M_CH_VALUE_TRG.xml	Fri Mar 01 11:14:11 2013 +0100
@@ -0,0 +1,95 @@
+<?xml version="1.0"?>
+  <database name="TRIGGER M_CH_VALUE_TRG">
+    <trigger name="M_CH_VALUE_TRG" table="M_CH_VALUE" fires="after" insert="true" update="false" delete="true" 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) 2013 Openbravo SLU
+* All Rights Reserved.
+* Contributor(s):  ______________________________________.
+************************************************************************/
+
+  v_Tree_ID           VARCHAR2(32);
+  v_Parent_ID         VARCHAR2(32);
+  v_NextNo            VARCHAR2(32);
+  v_count             NUMBER;
+
+BEGIN
+  IF (AD_isTriggerEnabled()='N') THEN
+    RETURN;
+  END IF;
+  -- Insert C_ElementValue Trigger
+  --  for Translation
+  --  and TreeNode
+  IF INSERTING THEN
+    --  Create TreeNode --
+    --  get AD_Tree_ID + ParentID
+    SELECT ch.ad_tree_id, n.node_id
+      INTO v_tree_id, v_parent_id
+    FROM m_characteristic ch JOIN ad_treenode n ON ch.ad_tree_id = n.ad_tree_id
+    WHERE n.parent_id IS NULL
+      AND ch.m_characteristic_id = :NEW.m_characteristic_id;
+
+    SELECT count(*) INTO v_count
+    FROM ad_treenode
+    WHERE node_id = :NEW.m_ch_value_id
+      AND ad_tree_id = v_tree_id;
+
+    IF (v_Count = 0) THEN 
+      --  Insert into TreeNode
+      INSERT INTO ad_treenode (
+          ad_treenode_id, ad_client_id, ad_org_id, isactive,
+          created, createdby, updated, updatedby,
+          ad_tree_id, node_id, parent_id,
+          seqno
+      ) VALUES (
+          get_uuid(), :NEW.ad_client_id, :NEW.ad_org_id, :NEW.isactive,
+          :NEW.created, :NEW.createdby, :NEW.updated, :NEW.updatedby,
+          v_tree_id, :NEW.m_ch_value_id, v_parent_id,
+          -- Summary Nodes first
+          CASE :NEW.issummary
+            WHEN 'Y' THEN 100
+            ELSE 999
+          END
+      );
+    END IF;
+  END IF;
+
+  IF DELETING THEN
+    --  Delete TreeNode --
+    SELECT ch.ad_tree_id INTO v_tree_id
+    FROM m_characteristic ch
+    WHERE ch.m_characteristic_id = :OLD.m_characteristic_id;
+
+    SELECT count(*) INTO v_count
+    FROM ad_treenode
+    WHERE ad_client_id = :OLD.ad_client_id
+      AND ad_tree_id = v_tree_id
+      AND parent_id = :OLD.m_ch_value_id;
+    IF (v_count>0) THEN
+      RAISE_APPLICATION_ERROR(-20000, '@ElementHasChildren@');
+    END IF;
+
+    DELETE FROM ad_treenode
+    WHERE ad_client_id = :OLD.ad_client_id
+      AND ad_tree_id = v_tree_id
+      AND node_id = :OLD.m_ch_value_id;
+  END IF;
+EXCEPTION
+WHEN NO_DATA_FOUND THEN
+  -- No tree found in the characteristic
+  RAISE_APPLICATION_ERROR(-20000, '@20013@') ;
+END M_CH_VALUE_TRG
+]]></body>
+    </trigger>
+  </database>
--- a/src-db/database/sourcedata/AD_COLUMN.xml	Thu Feb 28 18:36:35 2013 +0100
+++ b/src-db/database/sourcedata/AD_COLUMN.xml	Fri Mar 01 11:14:11 2013 +0100
@@ -309999,6 +309999,42 @@
 <!--D6C6D9A44360FD26E040007F01000176-->  <ISUSEDSEQUENCE><![CDATA[N]]></ISUSEDSEQUENCE>
 <!--D6C6D9A44360FD26E040007F01000176--></AD_COLUMN>
 
+<!--D6CB05B4109E3F11E040007F01001525--><AD_COLUMN>
+<!--D6CB05B4109E3F11E040007F01001525-->  <AD_COLUMN_ID><![CDATA[D6CB05B4109E3F11E040007F01001525]]></AD_COLUMN_ID>
+<!--D6CB05B4109E3F11E040007F01001525-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
+<!--D6CB05B4109E3F11E040007F01001525-->  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
+<!--D6CB05B4109E3F11E040007F01001525-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
+<!--D6CB05B4109E3F11E040007F01001525-->  <NAME><![CDATA[Tree]]></NAME>
+<!--D6CB05B4109E3F11E040007F01001525-->  <DESCRIPTION><![CDATA[Identifies a Tree]]></DESCRIPTION>
+<!--D6CB05B4109E3F11E040007F01001525-->  <HELP><![CDATA[The Tree field identifies a unique Tree in the system. Trees define roll ups or summary levels of information.  They are used in reports for defining report points and summarization levels.]]></HELP>
+<!--D6CB05B4109E3F11E040007F01001525-->  <COLUMNNAME><![CDATA[AD_Tree_ID]]></COLUMNNAME>
+<!--D6CB05B4109E3F11E040007F01001525-->  <AD_TABLE_ID><![CDATA[91C26DEA4B3D4C05B4F277D009220872]]></AD_TABLE_ID>
+<!--D6CB05B4109E3F11E040007F01001525-->  <AD_REFERENCE_ID><![CDATA[19]]></AD_REFERENCE_ID>
+<!--D6CB05B4109E3F11E040007F01001525-->  <AD_VAL_RULE_ID><![CDATA[64483C2BE00D40C3BDD3394E84EDA8A6]]></AD_VAL_RULE_ID>
+<!--D6CB05B4109E3F11E040007F01001525-->  <FIELDLENGTH><![CDATA[32]]></FIELDLENGTH>
+<!--D6CB05B4109E3F11E040007F01001525-->  <ISKEY><![CDATA[N]]></ISKEY>
+<!--D6CB05B4109E3F11E040007F01001525-->  <ISPARENT><![CDATA[N]]></ISPARENT>
+<!--D6CB05B4109E3F11E040007F01001525-->  <ISMANDATORY><![CDATA[Y]]></ISMANDATORY>
+<!--D6CB05B4109E3F11E040007F01001525-->  <ISUPDATEABLE><![CDATA[N]]></ISUPDATEABLE>
+<!--D6CB05B4109E3F11E040007F01001525-->  <ISIDENTIFIER><![CDATA[N]]></ISIDENTIFIER>
+<!--D6CB05B4109E3F11E040007F01001525-->  <SEQNO><![CDATA[120]]></SEQNO>
+<!--D6CB05B4109E3F11E040007F01001525-->  <ISTRANSLATED><![CDATA[N]]></ISTRANSLATED>
+<!--D6CB05B4109E3F11E040007F01001525-->  <ISENCRYPTED><![CDATA[N]]></ISENCRYPTED>
+<!--D6CB05B4109E3F11E040007F01001525-->  <ISSELECTIONCOLUMN><![CDATA[N]]></ISSELECTIONCOLUMN>
+<!--D6CB05B4109E3F11E040007F01001525-->  <AD_ELEMENT_ID><![CDATA[132]]></AD_ELEMENT_ID>
+<!--D6CB05B4109E3F11E040007F01001525-->  <ISSESSIONATTR><![CDATA[N]]></ISSESSIONATTR>
+<!--D6CB05B4109E3F11E040007F01001525-->  <ISSECONDARYKEY><![CDATA[N]]></ISSECONDARYKEY>
+<!--D6CB05B4109E3F11E040007F01001525-->  <ISDESENCRYPTABLE><![CDATA[N]]></ISDESENCRYPTABLE>
+<!--D6CB05B4109E3F11E040007F01001525-->  <DEVELOPMENTSTATUS><![CDATA[RE]]></DEVELOPMENTSTATUS>
+<!--D6CB05B4109E3F11E040007F01001525-->  <AD_MODULE_ID><![CDATA[0]]></AD_MODULE_ID>
+<!--D6CB05B4109E3F11E040007F01001525-->  <POSITION><![CDATA[12]]></POSITION>
+<!--D6CB05B4109E3F11E040007F01001525-->  <ISTRANSIENT><![CDATA[N]]></ISTRANSIENT>
+<!--D6CB05B4109E3F11E040007F01001525-->  <ISAUTOSAVE><![CDATA[Y]]></ISAUTOSAVE>
+<!--D6CB05B4109E3F11E040007F01001525-->  <VALIDATEONNEW><![CDATA[Y]]></VALIDATEONNEW>
+<!--D6CB05B4109E3F11E040007F01001525-->  <IMAGESIZEVALUESACTION><![CDATA[N]]></IMAGESIZEVALUESACTION>
+<!--D6CB05B4109E3F11E040007F01001525-->  <ISUSEDSEQUENCE><![CDATA[N]]></ISUSEDSEQUENCE>
+<!--D6CB05B4109E3F11E040007F01001525--></AD_COLUMN>
+
 <!--D781BB443D72453A8CB89BE9B210F206--><AD_COLUMN>
 <!--D781BB443D72453A8CB89BE9B210F206-->  <AD_COLUMN_ID><![CDATA[D781BB443D72453A8CB89BE9B210F206]]></AD_COLUMN_ID>
 <!--D781BB443D72453A8CB89BE9B210F206-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
--- a/src-db/database/sourcedata/AD_FIELD.xml	Thu Feb 28 18:36:35 2013 +0100
+++ b/src-db/database/sourcedata/AD_FIELD.xml	Fri Mar 01 11:14:11 2013 +0100
@@ -264872,7 +264872,7 @@
 <!--D69FE5884FF79B6BE040007F010015AE-->  <ISDISPLAYED><![CDATA[Y]]></ISDISPLAYED>
 <!--D69FE5884FF79B6BE040007F010015AE-->  <DISPLAYLENGTH><![CDATA[1]]></DISPLAYLENGTH>
 <!--D69FE5884FF79B6BE040007F010015AE-->  <ISREADONLY><![CDATA[N]]></ISREADONLY>
-<!--D69FE5884FF79B6BE040007F010015AE-->  <SEQNO><![CDATA[50]]></SEQNO>
+<!--D69FE5884FF79B6BE040007F010015AE-->  <SEQNO><![CDATA[60]]></SEQNO>
 <!--D69FE5884FF79B6BE040007F010015AE-->  <ISSAMELINE><![CDATA[N]]></ISSAMELINE>
 <!--D69FE5884FF79B6BE040007F010015AE-->  <ISFIELDONLY><![CDATA[N]]></ISFIELDONLY>
 <!--D69FE5884FF79B6BE040007F010015AE-->  <ISENCRYPTED><![CDATA[N]]></ISENCRYPTED>
@@ -264955,7 +264955,7 @@
 <!--D69FE5884FFA9B6BE040007F010015AE-->  <ISDISPLAYED><![CDATA[Y]]></ISDISPLAYED>
 <!--D69FE5884FFA9B6BE040007F010015AE-->  <DISPLAYLENGTH><![CDATA[2000]]></DISPLAYLENGTH>
 <!--D69FE5884FFA9B6BE040007F010015AE-->  <ISREADONLY><![CDATA[N]]></ISREADONLY>
-<!--D69FE5884FFA9B6BE040007F010015AE-->  <SEQNO><![CDATA[40]]></SEQNO>
+<!--D69FE5884FFA9B6BE040007F010015AE-->  <SEQNO><![CDATA[50]]></SEQNO>
 <!--D69FE5884FFA9B6BE040007F010015AE-->  <ISSAMELINE><![CDATA[N]]></ISSAMELINE>
 <!--D69FE5884FFA9B6BE040007F010015AE-->  <ISFIELDONLY><![CDATA[N]]></ISFIELDONLY>
 <!--D69FE5884FFA9B6BE040007F010015AE-->  <ISENCRYPTED><![CDATA[N]]></ISENCRYPTED>
@@ -265495,6 +265495,34 @@
 <!--D6CA6CA3874545698B30CDC2FBE6328C-->  <EM_OBUIAPP_SHOWSUMMARY><![CDATA[N]]></EM_OBUIAPP_SHOWSUMMARY>
 <!--D6CA6CA3874545698B30CDC2FBE6328C--></AD_FIELD>
 
+<!--D6CBFD85215F563DE040007F0100228D--><AD_FIELD>
+<!--D6CBFD85215F563DE040007F0100228D-->  <AD_FIELD_ID><![CDATA[D6CBFD85215F563DE040007F0100228D]]></AD_FIELD_ID>
+<!--D6CBFD85215F563DE040007F0100228D-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
+<!--D6CBFD85215F563DE040007F0100228D-->  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
+<!--D6CBFD85215F563DE040007F0100228D-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
+<!--D6CBFD85215F563DE040007F0100228D-->  <NAME><![CDATA[Tree]]></NAME>
+<!--D6CBFD85215F563DE040007F0100228D-->  <DESCRIPTION><![CDATA[Identifies a Tree]]></DESCRIPTION>
+<!--D6CBFD85215F563DE040007F0100228D-->  <HELP><![CDATA[The Tree field identifies a unique Tree in the system. Trees define roll ups or summary levels of information.  They are used in reports for defining report points and summarization levels.]]></HELP>
+<!--D6CBFD85215F563DE040007F0100228D-->  <ISCENTRALLYMAINTAINED><![CDATA[Y]]></ISCENTRALLYMAINTAINED>
+<!--D6CBFD85215F563DE040007F0100228D-->  <AD_TAB_ID><![CDATA[A661A0A05DCD4650BCB14B010C87F0AA]]></AD_TAB_ID>
+<!--D6CBFD85215F563DE040007F0100228D-->  <AD_COLUMN_ID><![CDATA[D6CB05B4109E3F11E040007F01001525]]></AD_COLUMN_ID>
+<!--D6CBFD85215F563DE040007F0100228D-->  <IGNOREINWAD><![CDATA[N]]></IGNOREINWAD>
+<!--D6CBFD85215F563DE040007F0100228D-->  <ISDISPLAYED><![CDATA[N]]></ISDISPLAYED>
+<!--D6CBFD85215F563DE040007F0100228D-->  <DISPLAYLENGTH><![CDATA[32]]></DISPLAYLENGTH>
+<!--D6CBFD85215F563DE040007F0100228D-->  <ISREADONLY><![CDATA[N]]></ISREADONLY>
+<!--D6CBFD85215F563DE040007F0100228D-->  <SEQNO><![CDATA[40]]></SEQNO>
+<!--D6CBFD85215F563DE040007F0100228D-->  <ISSAMELINE><![CDATA[N]]></ISSAMELINE>
+<!--D6CBFD85215F563DE040007F0100228D-->  <ISFIELDONLY><![CDATA[N]]></ISFIELDONLY>
+<!--D6CBFD85215F563DE040007F0100228D-->  <ISENCRYPTED><![CDATA[N]]></ISENCRYPTED>
+<!--D6CBFD85215F563DE040007F0100228D-->  <SHOWINRELATION><![CDATA[N]]></SHOWINRELATION>
+<!--D6CBFD85215F563DE040007F0100228D-->  <ISFIRSTFOCUSEDFIELD><![CDATA[N]]></ISFIRSTFOCUSEDFIELD>
+<!--D6CBFD85215F563DE040007F0100228D-->  <AD_MODULE_ID><![CDATA[0]]></AD_MODULE_ID>
+<!--D6CBFD85215F563DE040007F0100228D-->  <STARTINODDCOLUMN><![CDATA[N]]></STARTINODDCOLUMN>
+<!--D6CBFD85215F563DE040007F0100228D-->  <STARTNEWLINE><![CDATA[N]]></STARTNEWLINE>
+<!--D6CBFD85215F563DE040007F0100228D-->  <ISSHOWNINSTATUSBAR><![CDATA[N]]></ISSHOWNINSTATUSBAR>
+<!--D6CBFD85215F563DE040007F0100228D-->  <EM_OBUIAPP_SHOWSUMMARY><![CDATA[N]]></EM_OBUIAPP_SHOWSUMMARY>
+<!--D6CBFD85215F563DE040007F0100228D--></AD_FIELD>
+
 <!--D6FAD948F98F45679B3A9202A905E389--><AD_FIELD>
 <!--D6FAD948F98F45679B3A9202A905E389-->  <AD_FIELD_ID><![CDATA[D6FAD948F98F45679B3A9202A905E389]]></AD_FIELD_ID>
 <!--D6FAD948F98F45679B3A9202A905E389-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
--- a/src-db/database/sourcedata/AD_REF_LIST.xml	Thu Feb 28 18:36:35 2013 +0100
+++ b/src-db/database/sourcedata/AD_REF_LIST.xml	Fri Mar 01 11:14:11 2013 +0100
@@ -9704,6 +9704,17 @@
 <!--7CF20E12800D4B54A493CE90C90F767B-->  <AD_MODULE_ID><![CDATA[0]]></AD_MODULE_ID>
 <!--7CF20E12800D4B54A493CE90C90F767B--></AD_REF_LIST>
 
+<!--7D10DB31B24A4ACAA68FAB36DA3F82FB--><AD_REF_LIST>
+<!--7D10DB31B24A4ACAA68FAB36DA3F82FB-->  <AD_REF_LIST_ID><![CDATA[7D10DB31B24A4ACAA68FAB36DA3F82FB]]></AD_REF_LIST_ID>
+<!--7D10DB31B24A4ACAA68FAB36DA3F82FB-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
+<!--7D10DB31B24A4ACAA68FAB36DA3F82FB-->  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
+<!--7D10DB31B24A4ACAA68FAB36DA3F82FB-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
+<!--7D10DB31B24A4ACAA68FAB36DA3F82FB-->  <VALUE><![CDATA[CH]]></VALUE>
+<!--7D10DB31B24A4ACAA68FAB36DA3F82FB-->  <NAME><![CDATA[Product Characteristic]]></NAME>
+<!--7D10DB31B24A4ACAA68FAB36DA3F82FB-->  <AD_REFERENCE_ID><![CDATA[120]]></AD_REFERENCE_ID>
+<!--7D10DB31B24A4ACAA68FAB36DA3F82FB-->  <AD_MODULE_ID><![CDATA[0]]></AD_MODULE_ID>
+<!--7D10DB31B24A4ACAA68FAB36DA3F82FB--></AD_REF_LIST>
+
 <!--7E67333C2FC749B780E70A8DF91891AF--><AD_REF_LIST>
 <!--7E67333C2FC749B780E70A8DF91891AF-->  <AD_REF_LIST_ID><![CDATA[7E67333C2FC749B780E70A8DF91891AF]]></AD_REF_LIST_ID>
 <!--7E67333C2FC749B780E70A8DF91891AF-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
--- a/src-db/database/sourcedata/AD_TAB.xml	Thu Feb 28 18:36:35 2013 +0100
+++ b/src-db/database/sourcedata/AD_TAB.xml	Fri Mar 01 11:14:11 2013 +0100
@@ -12554,7 +12554,7 @@
 <!--367D9DF685DA42A38CAE641D30A0BEBF-->  <ISINFOTAB><![CDATA[N]]></ISINFOTAB>
 <!--367D9DF685DA42A38CAE641D30A0BEBF-->  <ISTRANSLATIONTAB><![CDATA[N]]></ISTRANSLATIONTAB>
 <!--367D9DF685DA42A38CAE641D30A0BEBF-->  <ISREADONLY><![CDATA[N]]></ISREADONLY>
-<!--367D9DF685DA42A38CAE641D30A0BEBF-->  <HASTREE><![CDATA[N]]></HASTREE>
+<!--367D9DF685DA42A38CAE641D30A0BEBF-->  <HASTREE><![CDATA[Y]]></HASTREE>
 <!--367D9DF685DA42A38CAE641D30A0BEBF-->  <PROCESSING><![CDATA[N]]></PROCESSING>
 <!--367D9DF685DA42A38CAE641D30A0BEBF-->  <IMPORTFIELDS><![CDATA[N]]></IMPORTFIELDS>
 <!--367D9DF685DA42A38CAE641D30A0BEBF-->  <ISSORTTAB><![CDATA[N]]></ISSORTTAB>
--- a/src-db/database/sourcedata/AD_VAL_RULE.xml	Thu Feb 28 18:36:35 2013 +0100
+++ b/src-db/database/sourcedata/AD_VAL_RULE.xml	Fri Mar 01 11:14:11 2013 +0100
@@ -1546,6 +1546,17 @@
 <!--62E3AF93FD914D09A89E77DA72D2E32A-->  <AD_MODULE_ID><![CDATA[0]]></AD_MODULE_ID>
 <!--62E3AF93FD914D09A89E77DA72D2E32A--></AD_VAL_RULE>
 
+<!--64483C2BE00D40C3BDD3394E84EDA8A6--><AD_VAL_RULE>
+<!--64483C2BE00D40C3BDD3394E84EDA8A6-->  <AD_VAL_RULE_ID><![CDATA[64483C2BE00D40C3BDD3394E84EDA8A6]]></AD_VAL_RULE_ID>
+<!--64483C2BE00D40C3BDD3394E84EDA8A6-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
+<!--64483C2BE00D40C3BDD3394E84EDA8A6-->  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
+<!--64483C2BE00D40C3BDD3394E84EDA8A6-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
+<!--64483C2BE00D40C3BDD3394E84EDA8A6-->  <NAME><![CDATA[AD_Tree Client Product Characteristic]]></NAME>
+<!--64483C2BE00D40C3BDD3394E84EDA8A6-->  <TYPE><![CDATA[S]]></TYPE>
+<!--64483C2BE00D40C3BDD3394E84EDA8A6-->  <CODE><![CDATA[AD_Tree.AD_Client_ID = @AD_Client_ID@ and AD_Tree.TreeType = 'CH']]></CODE>
+<!--64483C2BE00D40C3BDD3394E84EDA8A6-->  <AD_MODULE_ID><![CDATA[0]]></AD_MODULE_ID>
+<!--64483C2BE00D40C3BDD3394E84EDA8A6--></AD_VAL_RULE>
+
 <!--6726023D1780453A8088247C032F1B03--><AD_VAL_RULE>
 <!--6726023D1780453A8088247C032F1B03-->  <AD_VAL_RULE_ID><![CDATA[6726023D1780453A8088247C032F1B03]]></AD_VAL_RULE_ID>
 <!--6726023D1780453A8088247C032F1B03-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
--- a/src/org/openbravo/erpCommon/businessUtility/InitialClientSetup.java	Thu Feb 28 18:36:35 2013 +0100
+++ b/src/org/openbravo/erpCommon/businessUtility/InitialClientSetup.java	Fri Mar 01 11:14:11 2013 +0100
@@ -72,12 +72,13 @@
   private static final String STRTREETYPEUSERDIMENSION1 = "U1";
   private static final String STRTREETYPEUSERDIMENSION2 = "U2";
   private static final String STRTREETYPEOBRE_RESOURCECATEGORY = "OBRE_RC";
+  private static final String STRTREETYPEPRODUCTCHARACTERISTIC = "CH";
   private static final String STRSEPARATOR = "*****************************************************";
   private static final String STRCLIENTNAMESUFFIX = " Admin";
   private boolean bAccountingCreated = false;
   private Tree treeOrg, treeBPartner, treeProject, treeSalesRegion, treeProduct, treeAccount,
       treeMenu, treeCampaign, treeAsset, treeProductCategory, treeCostcenter, treeUserDimension1,
-      treeUserDimension2, treeOBRE_ResourceCategory;
+      treeUserDimension2, treeOBRE_ResourceCategory, treeProductCharacteristic;
   private Client client;
   private Role role;
   private Currency currency;
@@ -364,6 +365,9 @@
     } else if (strTreeType.endsWith(STRTREETYPEUSERDIMENSION2)) {
       treeUserDimension2 = tree;
       return;
+    } else if (strTreeType.endsWith(STRTREETYPEPRODUCTCHARACTERISTIC)) {
+      treeProductCharacteristic = tree;
+      return;
     }
   }
 
@@ -373,7 +377,7 @@
         || treeProject == null || treeSalesRegion == null || treeProduct == null
         || treeCampaign == null || treeAsset == null || treeProductCategory == null
         || treeCostcenter == null || treeUserDimension1 == null || treeUserDimension2 == null
-        || treeOBRE_ResourceCategory == null) {
+        || treeOBRE_ResourceCategory == null || treeProductCharacteristic == null) {
       return logErrorAndRollback("@CreateClientFailed@",
           "insertClientInfo() - ERROR - Required information is not present. "
               + "Please check that client and trees where correctly created.");
--- a/src/org/openbravo/erpCommon/utility/WindowTreeChecks.java	Thu Feb 28 18:36:35 2013 +0100
+++ b/src/org/openbravo/erpCommon/utility/WindowTreeChecks.java	Fri Mar 01 11:14:11 2013 +0100
@@ -150,6 +150,8 @@
       result = "";
     } else if (TreeType.equals("U2")) { // User Defined Dimension 2
       result = "";
+    } else if (TreeType.equals("CH")) { // Product Characteristic
+      result = "";
     } else
       result = WindowTreeChecksClient.checkChanges(conn, vars, tabId, topNodeId, nodeId, isChild,
           TreeType, key);
--- a/src/org/openbravo/erpCommon/utility/WindowTreeUtility.java	Thu Feb 28 18:36:35 2013 +0100
+++ b/src/org/openbravo/erpCommon/utility/WindowTreeUtility.java	Fri Mar 01 11:14:11 2013 +0100
@@ -81,7 +81,9 @@
       TreeType = "AS";
     else if (keyColumnName.equals("Obre_Resource_Category_ID"))
       TreeType = "OBRE_RC";
-    else
+    else if (keyColumnName.equals("M_Ch_Value_ID")) {
+      TreeType = "CH";
+    } else
       TreeType = "";
     if (TreeType.equals(""))
       log4j.error("WindowTreeUtility.getTreeID() - Could not map " + keyColumnName);
@@ -156,6 +158,12 @@
     else if (TreeType.equals("OBRE_RC"))
       data = WindowTreeData.selectOBRE_ResouceCategory(conn, "OBRE_Resource_Category_ID",
           "OBRE_Resource_Category", TreeID, strEditable, strParentID, strNodeId);
+    else if (TreeType.equals("CH")) {
+      String strCharacteristicId = vars.getSessionValue(Utility.getWindowID(conn, strTabID)
+          + "|M_Characteristic_ID");
+      data = WindowTreeData.selectChValue(conn, strEditable, strParentID, strNodeId, TreeID,
+          strCharacteristicId);
+    }
 
     return data;
   }
--- a/src/org/openbravo/erpCommon/utility/WindowTree_data.xsql	Thu Feb 28 18:36:35 2013 +0100
+++ b/src/org/openbravo/erpCommon/utility/WindowTree_data.xsql	Fri Mar 01 11:14:11 2013 +0100
@@ -301,6 +301,22 @@
         <Parameter name="parentId" optional="true" after="AND 2=2 " text="AND tn.Parent_ID = ? "/>
         <Parameter name="nodeId" optional="true" after="AND 2=2 " text="AND tn.Node_ID = ? "/>
    </SqlMethod>
+   <SqlMethod name="selectChValue" type="preparedStatement" return="multiple">
+      <SqlMethodComment></SqlMethodComment>
+      <Sql>
+        SELECT tn.Node_ID, tn.Parent_ID, tn.SeqNo, m.m_ch_value_id AS ID,
+            m.name AS Name, '' as description, m.IsSummary 
+        FROM m_ch_value m JOIN AD_TreeNode tn ON tn.Node_ID = m.m_ch_value_id
+        WHERE tn.AD_Tree_ID = ? 
+          AND m.m_characteristic_id = ? 
+        ORDER BY COALESCE(tn.Parent_ID, '-1'), tn.SeqNo
+      </Sql>
+        <Parameter name="editable" optional="true" type="none" after="WHERE " text="tn.IsActive='Y' AND m.isActive='Y' AND "/>
+        <Parameter name="parentId" optional="true" after="WHERE " text="tn.Parent_ID = ? AND "/>
+        <Parameter name="nodeId" optional="true" after="WHERE " text="tn.Node_ID = ? AND "/>
+        <Parameter name="adTreeId"/>
+        <Parameter name="mCharacteristicId"/>
+   </SqlMethod>
    <SqlMethod name="selectTreeID" type="preparedStatement" return="multiple">
       <SqlMethodComment></SqlMethodComment>
       <Sql>