[Production-Development] fb: CopyVersion
authorrafaeldemiguel <rdm@openbravo.com>
Thu, 27 Oct 2011 17:52:41 +0200
changeset 15005 74bf1e05bc72
parent 15004 a5826ec3994b
child 15006 0170674e481f
[Production-Development] fb: CopyVersion
src-db/database/model/functions/MA_COPY_VERSION.xml
src-db/database/model/tables/MA_SEQUENCEPRODUCT.xml
src-db/database/model/tables/MA_SEQUENCEPRODUCTATT.xml
src-db/database/sourcedata/AD_COLUMN.xml
src-db/database/sourcedata/AD_FIELD.xml
src-db/database/sourcedata/AD_REF_TABLE.xml
src-db/database/sourcedata/AD_TAB.xml
src-util/modulescript/build/classes/org/openbravo/modulescript/CreateLineForSequenceProduct.class
src-util/modulescript/src/org/openbravo/modulescript/CreateLineForSequenceProduct.java
src-util/modulescript/src/org/openbravo/modulescript/CreateLineForSequenceProduct_Data.xsql
--- a/src-db/database/model/functions/MA_COPY_VERSION.xml	Tue Oct 25 13:59:44 2011 +0200
+++ b/src-db/database/model/functions/MA_COPY_VERSION.xml	Thu Oct 27 17:52:41 2011 +0200
@@ -39,6 +39,7 @@
     v_Sequence_ID VARCHAR2(32);
     v_Product_ID VARCHAR2(32);
     v_ProductAtt_ID VARCHAR2(32);
+    v_MASequenceProductFrom_ID VARCHAR2(32);
     v_DateFrom DATE :=trunc(now());
     v_DateTo DATE :=TO_DATE('31-12-9999', 'DD-MM-YYYY');
     v_Count NUMBER;
@@ -146,6 +147,7 @@
         (SELECT *
         FROM MA_SequenceProduct
         WHERE MA_Sequence_ID=Cur_Sequence.MA_Sequence_ID
+        ORDER BY LINE
         )
       LOOP
         v_ResultStr:='InsertProducts';
@@ -158,7 +160,7 @@
             MA_Sequence_ID, M_Product_ID, Quantity, Productiontype,
             C_Uom_ID, Quantityorder, M_Product_Uom_ID, Componentcost,
             Decrease, Rejected, Uniqueattconsum, Copyproduct, 
-            Divisiongroupqty
+            Divisiongroupqty, Line
           )
           VALUES
           (
@@ -167,7 +169,7 @@
             v_Sequence_ID, Cur_Product.M_Product_ID, Cur_Product.Quantity, Cur_Product.Productiontype,
             Cur_Product.C_Uom_ID, Cur_Product.Quantityorder, Cur_Product.M_Product_Uom_ID, Cur_Product.Componentcost,
             Cur_Product.Decrease, Cur_Product.Rejected, Cur_Product.Uniqueattconsum, Cur_Product.Copyproduct,
-            Cur_Product.Divisiongroupqty
+            Cur_Product.Divisiongroupqty, Cur_Product.Line
           )
           ;
 	FOR Cur_ProductAtt IN
@@ -176,24 +178,35 @@
 	WHERE MA_SequenceProduct_ID=Cur_Product.MA_SequenceProduct_ID
 	)
 	LOOP
-	v_ResultStr:='InsertProductsCopyFromAttribute';
-	Ad_Sequence_Next('MA_SequenceProductAtt', v_Client_ID, v_ProductAtt_ID) ;
-	INSERT
-	INTO MA_SequenceProductatt
-	  (
-	    MA_SequenceProductatt_ID, AD_Client_ID, AD_Org_ID, Isactive,
-	    Created, Createdby, Updated, Updatedby,
-	    MA_Sequenceproduct_id, MA_Sequenceproductfrom_id, M_Attributeuseto_id, M_Attributeuse_id, 
-	    Isspecialatt, Specialatt
-	  )
-	  VALUES
-	  (
-	    v_ProductAtt_ID, v_Client_ID, v_Org_ID, 'Y',
-	    now(), COALESCE(v_User_ID, '0'), now(), COALESCE(v_User_ID, '0'),
-	    v_Product_ID, Cur_ProductAtt.MA_Sequenceproductfrom_id, Cur_ProductAtt.M_Attributeuseto_id, Cur_ProductAtt.M_Attributeuse_id, 
-	    Cur_ProductAtt.Isspecialatt, Cur_ProductAtt.Specialatt
-	  )
-	  ;
+		v_ResultStr:='InsertProductsCopyFromAttribute';
+		Ad_Sequence_Next('MA_SequenceProductAtt', v_Client_ID, v_ProductAtt_ID) ;
+
+		SELECT MA_SequenceProduct_ID
+		INTO v_MASequenceProductFrom_ID
+		FROM MA_SequenceProduct
+		WHERE MA_Sequence_ID = v_Sequence_ID
+		AND LINE = (SELECT LINE 
+				FROM MA_SequenceProduct
+				WHERE MA_SequenceProduct_ID = Cur_ProductAtt.MA_Sequenceproductfrom_id);
+
+		IF (v_MASequenceProductFrom_ID IS NOT NULL) THEN
+			INSERT
+			INTO MA_SequenceProductatt
+			  (
+			    MA_SequenceProductatt_ID, AD_Client_ID, AD_Org_ID, Isactive,
+			    Created, Createdby, Updated, Updatedby,
+			    MA_Sequenceproduct_id, MA_Sequenceproductfrom_id, M_Attributeuseto_id, M_Attributeuse_id, 
+			    Isspecialatt, Specialatt
+			  )
+			  VALUES
+			  (
+			    v_ProductAtt_ID, v_Client_ID, v_Org_ID, 'Y',
+			    now(), COALESCE(v_User_ID, '0'), now(), COALESCE(v_User_ID, '0'),
+			    v_Product_ID, v_MASequenceProductFrom_ID, Cur_ProductAtt.M_Attributeuseto_id, Cur_ProductAtt.M_Attributeuse_id, 
+			    Cur_ProductAtt.Isspecialatt, Cur_ProductAtt.Specialatt
+			  )
+			  ;
+		END IF;
 	END LOOP;
       END LOOP;
     END LOOP;
--- a/src-db/database/model/tables/MA_SEQUENCEPRODUCT.xml	Tue Oct 25 13:59:44 2011 +0200
+++ b/src-db/database/model/tables/MA_SEQUENCEPRODUCT.xml	Thu Oct 27 17:52:41 2011 +0200
@@ -89,6 +89,10 @@
         <default/>
         <onCreateDefault/>
       </column>
+      <column name="LINE" primaryKey="false" required="true" type="DECIMAL" size="10,0" autoIncrement="false">
+        <default/>
+        <onCreateDefault/>
+      </column>
       <foreign-key foreignTable="AD_ORG" name="AD_ORG_MASEQUENCEPRODUCT">
         <reference local="AD_ORG_ID" foreign="AD_ORG_ID"/>
       </foreign-key>
@@ -114,6 +118,10 @@
         <index-column name="M_PRODUCT_ID"/>
         <index-column name="MA_SEQUENCE_ID"/>
       </index>
+      <unique name="MA_SEQUENCEPRODUCT_LINE">
+        <unique-column name="MA_SEQUENCE_ID"/>
+        <unique-column name="LINE"/>
+      </unique>
       <check name="MA_SEQUENCEPROD_ISACTIVE_CHECK"><![CDATA[ISACTIVE IN ('Y', 'N')]]></check>
       <check name="MA_SEQUENCEPRODUCT_CHECK1"><![CDATA[((QUANTITYORDER IS NULL) AND (M_PRODUCT_UOM_ID IS NULL)) OR ((QUANTITYORDER IS NOT NULL) AND (M_PRODUCT_UOM_ID IS NOT NULL))]]></check>
     </table>
--- a/src-db/database/model/tables/MA_SEQUENCEPRODUCTATT.xml	Tue Oct 25 13:59:44 2011 +0200
+++ b/src-db/database/model/tables/MA_SEQUENCEPRODUCTATT.xml	Thu Oct 27 17:52:41 2011 +0200
@@ -75,6 +75,6 @@
       <foreign-key foreignTable="AD_CLIENT" name="MA_SEQUENCEATTPRODUCT_ADCLIENT">
         <reference local="AD_CLIENT_ID" foreign="AD_CLIENT_ID"/>
       </foreign-key>
-      <check name="MA_SEQUENCEPROD_ISACTIVE_CHECK"><![CDATA[ISACTIVE IN ('Y', 'N')]]></check>
+      <check name="MA_SEQATTPROD_ISACTIVE_CHECK"><![CDATA[ISACTIVE IN ('Y', 'N')]]></check>
     </table>
   </database>
--- a/src-db/database/sourcedata/AD_COLUMN.xml	Tue Oct 25 13:59:44 2011 +0200
+++ b/src-db/database/sourcedata/AD_COLUMN.xml	Thu Oct 27 17:52:41 2011 +0200
@@ -263809,6 +263809,40 @@
 <!--EAEDB737C7AD4AE8B656B3EE9E7673A1-->  <VALIDATEONNEW><![CDATA[Y]]></VALIDATEONNEW>
 <!--EAEDB737C7AD4AE8B656B3EE9E7673A1--></AD_COLUMN>
 
+<!--ECD90C86634B4A51B2FFCE7248293BED--><AD_COLUMN>
+<!--ECD90C86634B4A51B2FFCE7248293BED-->  <AD_COLUMN_ID><![CDATA[ECD90C86634B4A51B2FFCE7248293BED]]></AD_COLUMN_ID>
+<!--ECD90C86634B4A51B2FFCE7248293BED-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
+<!--ECD90C86634B4A51B2FFCE7248293BED-->  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
+<!--ECD90C86634B4A51B2FFCE7248293BED-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
+<!--ECD90C86634B4A51B2FFCE7248293BED-->  <NAME><![CDATA[Line No.]]></NAME>
+<!--ECD90C86634B4A51B2FFCE7248293BED-->  <DESCRIPTION><![CDATA[A line stating the position of this request in the document.]]></DESCRIPTION>
+<!--ECD90C86634B4A51B2FFCE7248293BED-->  <HELP><![CDATA[Indicates the unique line for a document.  It will also control the display order of the lines within a document.]]></HELP>
+<!--ECD90C86634B4A51B2FFCE7248293BED-->  <COLUMNNAME><![CDATA[Line]]></COLUMNNAME>
+<!--ECD90C86634B4A51B2FFCE7248293BED-->  <AD_TABLE_ID><![CDATA[800097]]></AD_TABLE_ID>
+<!--ECD90C86634B4A51B2FFCE7248293BED-->  <AD_REFERENCE_ID><![CDATA[11]]></AD_REFERENCE_ID>
+<!--ECD90C86634B4A51B2FFCE7248293BED-->  <FIELDLENGTH><![CDATA[12]]></FIELDLENGTH>
+<!--ECD90C86634B4A51B2FFCE7248293BED-->  <DEFAULTVALUE><![CDATA[@SQL=SELECT COALESCE(MAX(LINE),0)+10 AS DefaultValue FROM MA_SEQUENCEPRODUCT WHERE MA_SEQUENCE_ID=@Ma_Sequence_Id@]]></DEFAULTVALUE>
+<!--ECD90C86634B4A51B2FFCE7248293BED-->  <ISKEY><![CDATA[N]]></ISKEY>
+<!--ECD90C86634B4A51B2FFCE7248293BED-->  <ISPARENT><![CDATA[N]]></ISPARENT>
+<!--ECD90C86634B4A51B2FFCE7248293BED-->  <ISMANDATORY><![CDATA[Y]]></ISMANDATORY>
+<!--ECD90C86634B4A51B2FFCE7248293BED-->  <ISUPDATEABLE><![CDATA[Y]]></ISUPDATEABLE>
+<!--ECD90C86634B4A51B2FFCE7248293BED-->  <ISIDENTIFIER><![CDATA[N]]></ISIDENTIFIER>
+<!--ECD90C86634B4A51B2FFCE7248293BED-->  <SEQNO><![CDATA[350]]></SEQNO>
+<!--ECD90C86634B4A51B2FFCE7248293BED-->  <ISTRANSLATED><![CDATA[N]]></ISTRANSLATED>
+<!--ECD90C86634B4A51B2FFCE7248293BED-->  <ISENCRYPTED><![CDATA[N]]></ISENCRYPTED>
+<!--ECD90C86634B4A51B2FFCE7248293BED-->  <ISSELECTIONCOLUMN><![CDATA[N]]></ISSELECTIONCOLUMN>
+<!--ECD90C86634B4A51B2FFCE7248293BED-->  <AD_ELEMENT_ID><![CDATA[439]]></AD_ELEMENT_ID>
+<!--ECD90C86634B4A51B2FFCE7248293BED-->  <ISSESSIONATTR><![CDATA[Y]]></ISSESSIONATTR>
+<!--ECD90C86634B4A51B2FFCE7248293BED-->  <ISSECONDARYKEY><![CDATA[N]]></ISSECONDARYKEY>
+<!--ECD90C86634B4A51B2FFCE7248293BED-->  <ISDESENCRYPTABLE><![CDATA[N]]></ISDESENCRYPTABLE>
+<!--ECD90C86634B4A51B2FFCE7248293BED-->  <DEVELOPMENTSTATUS><![CDATA[RE]]></DEVELOPMENTSTATUS>
+<!--ECD90C86634B4A51B2FFCE7248293BED-->  <AD_MODULE_ID><![CDATA[0]]></AD_MODULE_ID>
+<!--ECD90C86634B4A51B2FFCE7248293BED-->  <POSITION><![CDATA[36]]></POSITION>
+<!--ECD90C86634B4A51B2FFCE7248293BED-->  <ISTRANSIENT><![CDATA[N]]></ISTRANSIENT>
+<!--ECD90C86634B4A51B2FFCE7248293BED-->  <ISAUTOSAVE><![CDATA[Y]]></ISAUTOSAVE>
+<!--ECD90C86634B4A51B2FFCE7248293BED-->  <VALIDATEONNEW><![CDATA[Y]]></VALIDATEONNEW>
+<!--ECD90C86634B4A51B2FFCE7248293BED--></AD_COLUMN>
+
 <!--EDE3D71386EA45EDA6F3DCB0D700A0A0--><AD_COLUMN>
 <!--EDE3D71386EA45EDA6F3DCB0D700A0A0-->  <AD_COLUMN_ID><![CDATA[EDE3D71386EA45EDA6F3DCB0D700A0A0]]></AD_COLUMN_ID>
 <!--EDE3D71386EA45EDA6F3DCB0D700A0A0-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
--- a/src-db/database/sourcedata/AD_FIELD.xml	Tue Oct 25 13:59:44 2011 +0200
+++ b/src-db/database/sourcedata/AD_FIELD.xml	Thu Oct 27 17:52:41 2011 +0200
@@ -163187,6 +163187,33 @@
 <!--0FEAE3D3D9D0433D8DE11C24EB9CFB5C-->  <ISSHOWNINSTATUSBAR><![CDATA[N]]></ISSHOWNINSTATUSBAR>
 <!--0FEAE3D3D9D0433D8DE11C24EB9CFB5C--></AD_FIELD>
 
+<!--10425745A5934C80904CFD69F96F4068--><AD_FIELD>
+<!--10425745A5934C80904CFD69F96F4068-->  <AD_FIELD_ID><![CDATA[10425745A5934C80904CFD69F96F4068]]></AD_FIELD_ID>
+<!--10425745A5934C80904CFD69F96F4068-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
+<!--10425745A5934C80904CFD69F96F4068-->  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
+<!--10425745A5934C80904CFD69F96F4068-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
+<!--10425745A5934C80904CFD69F96F4068-->  <NAME><![CDATA[Line No.]]></NAME>
+<!--10425745A5934C80904CFD69F96F4068-->  <DESCRIPTION><![CDATA[A line stating the position of this request in the document.]]></DESCRIPTION>
+<!--10425745A5934C80904CFD69F96F4068-->  <HELP><![CDATA[Indicates the unique line for a document.  It will also control the display order of the lines within a document.]]></HELP>
+<!--10425745A5934C80904CFD69F96F4068-->  <ISCENTRALLYMAINTAINED><![CDATA[Y]]></ISCENTRALLYMAINTAINED>
+<!--10425745A5934C80904CFD69F96F4068-->  <AD_TAB_ID><![CDATA[800110]]></AD_TAB_ID>
+<!--10425745A5934C80904CFD69F96F4068-->  <AD_COLUMN_ID><![CDATA[ECD90C86634B4A51B2FFCE7248293BED]]></AD_COLUMN_ID>
+<!--10425745A5934C80904CFD69F96F4068-->  <ISDISPLAYED><![CDATA[Y]]></ISDISPLAYED>
+<!--10425745A5934C80904CFD69F96F4068-->  <DISPLAYLENGTH><![CDATA[12]]></DISPLAYLENGTH>
+<!--10425745A5934C80904CFD69F96F4068-->  <ISREADONLY><![CDATA[N]]></ISREADONLY>
+<!--10425745A5934C80904CFD69F96F4068-->  <SEQNO><![CDATA[5]]></SEQNO>
+<!--10425745A5934C80904CFD69F96F4068-->  <ISSAMELINE><![CDATA[N]]></ISSAMELINE>
+<!--10425745A5934C80904CFD69F96F4068-->  <ISFIELDONLY><![CDATA[N]]></ISFIELDONLY>
+<!--10425745A5934C80904CFD69F96F4068-->  <ISENCRYPTED><![CDATA[N]]></ISENCRYPTED>
+<!--10425745A5934C80904CFD69F96F4068-->  <SHOWINRELATION><![CDATA[Y]]></SHOWINRELATION>
+<!--10425745A5934C80904CFD69F96F4068-->  <ISFIRSTFOCUSEDFIELD><![CDATA[N]]></ISFIRSTFOCUSEDFIELD>
+<!--10425745A5934C80904CFD69F96F4068-->  <AD_MODULE_ID><![CDATA[0]]></AD_MODULE_ID>
+<!--10425745A5934C80904CFD69F96F4068-->  <GRID_SEQNO><![CDATA[5]]></GRID_SEQNO>
+<!--10425745A5934C80904CFD69F96F4068-->  <STARTINODDCOLUMN><![CDATA[N]]></STARTINODDCOLUMN>
+<!--10425745A5934C80904CFD69F96F4068-->  <STARTNEWLINE><![CDATA[N]]></STARTNEWLINE>
+<!--10425745A5934C80904CFD69F96F4068-->  <ISSHOWNINSTATUSBAR><![CDATA[N]]></ISSHOWNINSTATUSBAR>
+<!--10425745A5934C80904CFD69F96F4068--></AD_FIELD>
+
 <!--104E8B74FC1A49A685AF98E2071D1FEF--><AD_FIELD>
 <!--104E8B74FC1A49A685AF98E2071D1FEF-->  <AD_FIELD_ID><![CDATA[104E8B74FC1A49A685AF98E2071D1FEF]]></AD_FIELD_ID>
 <!--104E8B74FC1A49A685AF98E2071D1FEF-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
--- a/src-db/database/sourcedata/AD_REF_TABLE.xml	Tue Oct 25 13:59:44 2011 +0200
+++ b/src-db/database/sourcedata/AD_REF_TABLE.xml	Thu Oct 27 17:52:41 2011 +0200
@@ -1280,7 +1280,7 @@
 <!--FF808181329203980132921324270015-->  <AD_KEY><![CDATA[801536]]></AD_KEY>
 <!--FF808181329203980132921324270015-->  <AD_DISPLAY><![CDATA[801546]]></AD_DISPLAY>
 <!--FF808181329203980132921324270015-->  <ISVALUEDISPLAYED><![CDATA[N]]></ISVALUEDISPLAYED>
-<!--FF808181329203980132921324270015-->  <WHERECLAUSE><![CDATA[MA_SequenceProduct.MA_Sequence_ID = @MA_Sequence_ID@ AND MA_SequenceProduct.Productiontype = '-']]></WHERECLAUSE>
+<!--FF808181329203980132921324270015-->  <WHERECLAUSE><![CDATA[MA_SequenceProduct.MA_Sequence_ID = @MA_Sequence_ID@ AND MA_SequenceProduct.Productiontype = '-'  AND MA_SequenceProduct.Line < TO_NUMBER(@Line@)]]></WHERECLAUSE>
 <!--FF808181329203980132921324270015--></AD_REF_TABLE>
 
 </data>
--- a/src-db/database/sourcedata/AD_TAB.xml	Tue Oct 25 13:59:44 2011 +0200
+++ b/src-db/database/sourcedata/AD_TAB.xml	Thu Oct 27 17:52:41 2011 +0200
@@ -7226,11 +7226,13 @@
 <!--800110-->  <ISTRANSLATIONTAB><![CDATA[N]]></ISTRANSLATIONTAB>
 <!--800110-->  <ISREADONLY><![CDATA[N]]></ISREADONLY>
 <!--800110-->  <HASTREE><![CDATA[N]]></HASTREE>
+<!--800110-->  <ORDERBYCLAUSE><![CDATA[line]]></ORDERBYCLAUSE>
 <!--800110-->  <PROCESSING><![CDATA[N]]></PROCESSING>
 <!--800110-->  <IMPORTFIELDS><![CDATA[N]]></IMPORTFIELDS>
 <!--800110-->  <ISSORTTAB><![CDATA[N]]></ISSORTTAB>
 <!--800110-->  <AD_MODULE_ID><![CDATA[0]]></AD_MODULE_ID>
 <!--800110-->  <UIPATTERN><![CDATA[STD]]></UIPATTERN>
+<!--800110-->  <HQLORDERBYCLAUSE><![CDATA[lineNo]]></HQLORDERBYCLAUSE>
 <!--800110-->  <SHOWPARENTBUTTONS><![CDATA[Y]]></SHOWPARENTBUTTONS>
 <!--800110--></AD_TAB>
 
Binary file src-util/modulescript/build/classes/org/openbravo/modulescript/CreateLineForSequenceProduct.class has changed
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src-util/modulescript/src/org/openbravo/modulescript/CreateLineForSequenceProduct.java	Thu Oct 27 17:52:41 2011 +0200
@@ -0,0 +1,49 @@
+/*
+ *************************************************************************
+ * 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) 2011 Openbravo SLU
+ * All Rights Reserved.
+ * Contributor(s):  ______________________________________.
+ ************************************************************************
+ */
+package org.openbravo.modulescript;
+
+import org.openbravo.database.ConnectionProvider;
+
+public class CreateLineForSequenceProduct extends ModuleScript {
+
+  @Override
+  // Filling Line in Sequence Products
+  public void execute() {
+    try {
+      ConnectionProvider cp = getConnectionProvider();
+      if (CreateLineForSequenceProductData.existsNull(cp)) {
+        CreateLineForSequenceProductData[] data = CreateLineForSequenceProductData.select(cp);
+        for (int i = 0; i < data.length; i++) {
+          CreateLineForSequenceProductData[] dataProducts = CreateLineForSequenceProductData
+              .selectSequenceProducts(cp, data[i].maSequenceId);
+          Integer lineNumber = 10;
+          for (int j = 0; j < dataProducts.length; j++) {
+            CreateLineForSequenceProductData.updateline(cp, lineNumber.toString(),
+                dataProducts[j].maSequenceproductId);
+            lineNumber = lineNumber + 10;
+          }
+        }
+      }
+    } catch (Exception e) {
+      handleError(e);
+    }
+
+  }
+
+}
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src-util/modulescript/src/org/openbravo/modulescript/CreateLineForSequenceProduct_Data.xsql	Thu Oct 27 17:52:41 2011 +0200
@@ -0,0 +1,63 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!--
+ *************************************************************************
+ * 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) 2011 Openbravo SLU
+ * All Rights Reserved.
+ * Contributor(s):  ______________________________________.
+ ************************************************************************
+-->
+<SqlClass name="CreateLineForSequenceProductData" package="org.openbravo.modulescript">
+   <SqlClassComment></SqlClassComment>
+   <SqlMethod name="select" type="preparedStatement" return="multiple">
+    <SqlMethodComment></SqlMethodComment>
+    <Sql>
+      <![CDATA[
+      SELECT MA_SEQUENCE.MA_SEQUENCE_ID, '' AS TOTAL, '' AS MA_SEQUENCEPRODUCT_ID
+      FROM MA_SEQUENCEPRODUCT 
+          JOIN MA_SEQUENCE ON MA_SEQUENCEPRODUCT.MA_SEQUENCE_ID = MA_SEQUENCE.MA_SEQUENCE_ID
+      WHERE MA_SEQUENCEPRODUCT.LINE IS NULL
+      GROUP BY MA_SEQUENCE.MA_SEQUENCE_ID
+      ]]>
+    </Sql>
+  </SqlMethod>
+  <SqlMethod name="existsNull" type="preparedStatement" return="boolean">
+      <SqlMethodComment></SqlMethodComment>
+      <Sql>
+        SELECT COUNT(1) FROM DUAL
+        WHERE EXISTS (SELECT 1 FROM MA_SEQUENCEPRODUCT WHERE LINE IS NULL)
+      </Sql>
+   </SqlMethod>
+   <SqlMethod name="selectSequenceProducts" type="preparedStatement" return="multiple">
+    <SqlMethodComment></SqlMethodComment>
+    <Sql>
+      <![CDATA[
+        SELECT MA_SEQUENCEPRODUCT_ID
+        FROM MA_SEQUENCEPRODUCT
+        WHERE MA_SEQUENCE_ID = ?
+        ORDER BY PRODUCTIONTYPE
+      ]]>
+    </Sql>
+    <Parameter name="maSequenceId"/>
+  </SqlMethod>
+  <SqlMethod name="updateline" type="preparedStatement" return="rowCount">
+    <SqlMethodComment></SqlMethodComment>
+    <Sql>
+      <![CDATA[
+      UPDATE MA_SEQUENCEPRODUCT SET LINE = TO_NUMBER(?) WHERE MA_SEQUENCEPRODUCT_ID = ?
+      ]]>
+    </Sql>
+    <Parameter name="line"/>
+    <Parameter name="maSequenceProductId"/>
+  </SqlMethod>
+</SqlClass>
\ No newline at end of file