commit 17991, 17992
authorPandeeswari Ramakrishnan <pandeeswari.ramakrishnan@openbravo.com>
Thu, 20 Sep 2012 12:39:59 +0200
changeset 18808 a3cfaac930ae
parent 18807 0c021a2f2c49
child 18809 1600af134deb
commit 17991, 17992
src-db/database/model/functions/C_INVOICE_POST.xml
src-db/database/model/functions/C_ORDER_POST1.xml
src-db/database/model/functions/M_INOUT_POST.xml
src-db/database/sourcedata/AD_FIELD.xml
src-db/database/sourcedata/AD_MESSAGE.xml
src/org/openbravo/erpCommon/ad_actionButton/CreateFrom.java
--- a/src-db/database/model/functions/C_INVOICE_POST.xml	Thu Sep 20 12:10:09 2012 +0200
+++ b/src-db/database/model/functions/C_INVOICE_POST.xml	Thu Sep 20 12:39:59 2012 +0200
@@ -459,11 +459,16 @@
     END;--FOR  COMMIT
     BEGIN -- FOR COMMIT
 
-      -- Set org lines like the headear
-      UPDATE C_INVOICELINE
-      SET AD_ORG_ID = (SELECT AD_ORG_ID FROM C_INVOICE WHERE C_INVOICE_ID = v_Record_ID),Updated=now(),
-          UpdatedBy=v_UpdatedBy
-      WHERE C_INVOICE_ID = v_Record_ID;
+      SELECT COUNT(*)
+        INTO v_Count
+      FROM C_INVOICE I, C_INVOICELINE IL
+      WHERE I.C_INVOICE_ID = IL.C_INVOICE_ID
+        AND AD_ISORGINCLUDED(IL.AD_Org_ID, I.AD_Org_ID, I.AD_Client_ID) <> -1
+        AND I.C_INVOICE_ID = v_Record_ID;
+      IF (v_Count=0) THEN
+        RAISE_APPLICATION_ERROR(-20000, '@NotCorrectOrgLines@') ;
+      END IF;
+
 
       SELECT COUNT(*) INTO v_Count
       FROM C_INVOICE C,
@@ -1341,12 +1346,7 @@
     SET AD_Client_ID=v_Client_ID
     WHERE C_Invoice_ID=v_Record_ID
       AND AD_Client_ID<>v_Client_ID;
-    v_ResultStr:='SyncOwnershipOrg';
-    UPDATE C_INVOICELINE
-    SET AD_Org_ID=v_Org_ID
-    WHERE C_Invoice_ID=v_Record_ID
-      AND C_Charge_ID IS NULL -- sync for products
-      AND AD_Org_ID<>v_Org_ID;
+
   END IF;--FINISH_PROCESS
   IF (NOT FINISH_PROCESS AND NOT END_PROCESSING) THEN
     /**************************************************************************
--- a/src-db/database/model/functions/C_ORDER_POST1.xml	Thu Sep 20 12:10:09 2012 +0200
+++ b/src-db/database/model/functions/C_ORDER_POST1.xml	Thu Sep 20 12:39:59 2012 +0200
@@ -412,10 +412,16 @@
         RAISE_APPLICATION_ERROR(-20000, '@NotCorrectOrgDoctypeOrder@') ;
       END IF;
 
-      -- Set org lines like the headear
-      UPDATE C_ORDERLINE
-      SET AD_ORG_ID = (SELECT AD_ORG_ID FROM C_ORDER WHERE C_ORDER_ID = v_Record_ID)
-      WHERE C_ORDER_ID = v_Record_ID;
+      SELECT COUNT(*)
+        INTO v_Count
+      FROM C_ORDER C, C_ORDERLINE OL
+      WHERE C.C_ORDER_ID = OL.C_ORDER_ID
+        AND AD_ISORGINCLUDED(OL.AD_Org_ID, C.AD_Org_ID, C.AD_Client_ID) <> -1
+        AND C.C_ORDER_ID = v_Record_ID;
+      IF (v_Count=0) THEN
+        RAISE_APPLICATION_ERROR(-20000, '@NotCorrectOrgLines@') ;
+      END IF;
+      
 
       /**
       * Close Order - prepare
@@ -1087,10 +1093,9 @@
       END; -- Calculate Tax and Totals
       -- Synchronize Client/Org Ownership
       UPDATE C_ORDERLINE
-      SET AD_Client_ID=v_Client_ID,
-          AD_Org_ID=v_Org_ID
+      SET AD_Client_ID=v_Client_ID
       WHERE C_Order_ID=v_Record_ID
-        AND (AD_Client_ID<>v_Client_ID OR AD_Org_ID<>v_Org_ID) ;
+        AND (AD_Client_ID<>v_Client_ID) ;
 
     /**************************************************************************
      * Order Complete:5 - Something to do:6
--- a/src-db/database/model/functions/M_INOUT_POST.xml	Thu Sep 20 12:10:09 2012 +0200
+++ b/src-db/database/model/functions/M_INOUT_POST.xml	Thu Sep 20 12:39:59 2012 +0200
@@ -226,12 +226,15 @@
     END IF;
         -- Process Shipments
   
-     -- Set org lines like the header
-       UPDATE M_INOUTLINE
-        SET AD_ORG_ID = (SELECT AD_ORG_ID FROM M_INOUT WHERE M_INOUT_ID = v_Record_ID),
-        Updated=now(),
-        UpdatedBy=v_User
-      WHERE M_INOUT_ID = v_Record_ID;
+      SELECT COUNT(*)
+        INTO v_Count
+      FROM M_INOUT IO, M_INOUTLINE IOL
+      WHERE IO.M_INOUT_ID = IOL.M_INOUT_ID
+        AND AD_ISORGINCLUDED(IOL.AD_Org_ID, IO.AD_Org_ID, IO.AD_Client_ID) <> -1
+        AND IO.M_INOUT_ID = v_Record_ID;
+      IF (v_Count=0) THEN
+        RAISE_APPLICATION_ERROR(-20000, '@NotCorrectOrgLines@') ;
+      END IF;
       
       -- Check the header belongs to a organization where transactions are posible and ready to use
       SELECT AD_Org.IsReady, Ad_OrgType.IsTransactionsAllowed
--- a/src-db/database/sourcedata/AD_FIELD.xml	Thu Sep 20 12:10:09 2012 +0200
+++ b/src-db/database/sourcedata/AD_FIELD.xml	Thu Sep 20 12:39:59 2012 +0200
@@ -23458,8 +23458,9 @@
 <!--2053-->  <ISCENTRALLYMAINTAINED><![CDATA[Y]]></ISCENTRALLYMAINTAINED>
 <!--2053-->  <AD_TAB_ID><![CDATA[187]]></AD_TAB_ID>
 <!--2053-->  <AD_COLUMN_ID><![CDATA[2207]]></AD_COLUMN_ID>
+<!--2053-->  <AD_FIELDGROUP_ID><![CDATA[800000]]></AD_FIELDGROUP_ID>
 <!--2053-->  <IGNOREINWAD><![CDATA[N]]></IGNOREINWAD>
-<!--2053-->  <ISDISPLAYED><![CDATA[N]]></ISDISPLAYED>
+<!--2053-->  <ISDISPLAYED><![CDATA[Y]]></ISDISPLAYED>
 <!--2053-->  <DISPLAYLENGTH><![CDATA[44]]></DISPLAYLENGTH>
 <!--2053-->  <ISREADONLY><![CDATA[N]]></ISREADONLY>
 <!--2053-->  <ISSAMELINE><![CDATA[Y]]></ISSAMELINE>
@@ -33918,8 +33919,9 @@
 <!--2712-->  <ISCENTRALLYMAINTAINED><![CDATA[Y]]></ISCENTRALLYMAINTAINED>
 <!--2712-->  <AD_TAB_ID><![CDATA[258]]></AD_TAB_ID>
 <!--2712-->  <AD_COLUMN_ID><![CDATA[3531]]></AD_COLUMN_ID>
+<!--2712-->  <AD_FIELDGROUP_ID><![CDATA[800000]]></AD_FIELDGROUP_ID>
 <!--2712-->  <IGNOREINWAD><![CDATA[N]]></IGNOREINWAD>
-<!--2712-->  <ISDISPLAYED><![CDATA[N]]></ISDISPLAYED>
+<!--2712-->  <ISDISPLAYED><![CDATA[Y]]></ISDISPLAYED>
 <!--2712-->  <DISPLAYLENGTH><![CDATA[44]]></DISPLAYLENGTH>
 <!--2712-->  <ISREADONLY><![CDATA[N]]></ISREADONLY>
 <!--2712-->  <ISSAMELINE><![CDATA[Y]]></ISSAMELINE>
@@ -37524,8 +37526,9 @@
 <!--2983-->  <ISCENTRALLYMAINTAINED><![CDATA[Y]]></ISCENTRALLYMAINTAINED>
 <!--2983-->  <AD_TAB_ID><![CDATA[270]]></AD_TAB_ID>
 <!--2983-->  <AD_COLUMN_ID><![CDATA[3830]]></AD_COLUMN_ID>
+<!--2983-->  <AD_FIELDGROUP_ID><![CDATA[800000]]></AD_FIELDGROUP_ID>
 <!--2983-->  <IGNOREINWAD><![CDATA[N]]></IGNOREINWAD>
-<!--2983-->  <ISDISPLAYED><![CDATA[N]]></ISDISPLAYED>
+<!--2983-->  <ISDISPLAYED><![CDATA[Y]]></ISDISPLAYED>
 <!--2983-->  <DISPLAYLENGTH><![CDATA[44]]></DISPLAYLENGTH>
 <!--2983-->  <ISREADONLY><![CDATA[N]]></ISREADONLY>
 <!--2983-->  <ISSAMELINE><![CDATA[Y]]></ISSAMELINE>
@@ -42535,8 +42538,9 @@
 <!--3359-->  <ISCENTRALLYMAINTAINED><![CDATA[Y]]></ISCENTRALLYMAINTAINED>
 <!--3359-->  <AD_TAB_ID><![CDATA[291]]></AD_TAB_ID>
 <!--3359-->  <AD_COLUMN_ID><![CDATA[3830]]></AD_COLUMN_ID>
+<!--3359-->  <AD_FIELDGROUP_ID><![CDATA[800000]]></AD_FIELDGROUP_ID>
 <!--3359-->  <IGNOREINWAD><![CDATA[N]]></IGNOREINWAD>
-<!--3359-->  <ISDISPLAYED><![CDATA[N]]></ISDISPLAYED>
+<!--3359-->  <ISDISPLAYED><![CDATA[Y]]></ISDISPLAYED>
 <!--3359-->  <DISPLAYLENGTH><![CDATA[44]]></DISPLAYLENGTH>
 <!--3359-->  <ISREADONLY><![CDATA[N]]></ISREADONLY>
 <!--3359-->  <ISSAMELINE><![CDATA[Y]]></ISSAMELINE>
@@ -43874,8 +43878,9 @@
 <!--3409-->  <ISCENTRALLYMAINTAINED><![CDATA[Y]]></ISCENTRALLYMAINTAINED>
 <!--3409-->  <AD_TAB_ID><![CDATA[293]]></AD_TAB_ID>
 <!--3409-->  <AD_COLUMN_ID><![CDATA[2207]]></AD_COLUMN_ID>
+<!--3409-->  <AD_FIELDGROUP_ID><![CDATA[800000]]></AD_FIELDGROUP_ID>
 <!--3409-->  <IGNOREINWAD><![CDATA[N]]></IGNOREINWAD>
-<!--3409-->  <ISDISPLAYED><![CDATA[N]]></ISDISPLAYED>
+<!--3409-->  <ISDISPLAYED><![CDATA[Y]]></ISDISPLAYED>
 <!--3409-->  <DISPLAYLENGTH><![CDATA[44]]></DISPLAYLENGTH>
 <!--3409-->  <ISREADONLY><![CDATA[N]]></ISREADONLY>
 <!--3409-->  <ISSAMELINE><![CDATA[Y]]></ISSAMELINE>
@@ -46544,8 +46549,9 @@
 <!--3509-->  <ISCENTRALLYMAINTAINED><![CDATA[Y]]></ISCENTRALLYMAINTAINED>
 <!--3509-->  <AD_TAB_ID><![CDATA[297]]></AD_TAB_ID>
 <!--3509-->  <AD_COLUMN_ID><![CDATA[3531]]></AD_COLUMN_ID>
+<!--3509-->  <AD_FIELDGROUP_ID><![CDATA[800000]]></AD_FIELDGROUP_ID>
 <!--3509-->  <IGNOREINWAD><![CDATA[N]]></IGNOREINWAD>
-<!--3509-->  <ISDISPLAYED><![CDATA[N]]></ISDISPLAYED>
+<!--3509-->  <ISDISPLAYED><![CDATA[Y]]></ISDISPLAYED>
 <!--3509-->  <DISPLAYLENGTH><![CDATA[44]]></DISPLAYLENGTH>
 <!--3509-->  <ISREADONLY><![CDATA[N]]></ISREADONLY>
 <!--3509-->  <ISSAMELINE><![CDATA[Y]]></ISSAMELINE>
--- a/src-db/database/sourcedata/AD_MESSAGE.xml	Thu Sep 20 12:10:09 2012 +0200
+++ b/src-db/database/sourcedata/AD_MESSAGE.xml	Thu Sep 20 12:39:59 2012 +0200
@@ -14618,6 +14618,17 @@
 <!--0A04D7BA3A1D466A82B15AE10CFFE252-->  <AD_MODULE_ID><![CDATA[0]]></AD_MODULE_ID>
 <!--0A04D7BA3A1D466A82B15AE10CFFE252--></AD_MESSAGE>
 
+<!--0BA839D8B467422AB19C8E1B3B033051--><AD_MESSAGE>
+<!--0BA839D8B467422AB19C8E1B3B033051-->  <AD_MESSAGE_ID><![CDATA[0BA839D8B467422AB19C8E1B3B033051]]></AD_MESSAGE_ID>
+<!--0BA839D8B467422AB19C8E1B3B033051-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
+<!--0BA839D8B467422AB19C8E1B3B033051-->  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
+<!--0BA839D8B467422AB19C8E1B3B033051-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
+<!--0BA839D8B467422AB19C8E1B3B033051-->  <VALUE><![CDATA[NotCorrectOrgLines]]></VALUE>
+<!--0BA839D8B467422AB19C8E1B3B033051-->  <MSGTEXT><![CDATA[The organization of the  lines  is different and does not depend on the organization associated with the header.]]></MSGTEXT>
+<!--0BA839D8B467422AB19C8E1B3B033051-->  <MSGTYPE><![CDATA[E]]></MSGTYPE>
+<!--0BA839D8B467422AB19C8E1B3B033051-->  <AD_MODULE_ID><![CDATA[0]]></AD_MODULE_ID>
+<!--0BA839D8B467422AB19C8E1B3B033051--></AD_MESSAGE>
+
 <!--0C093B834C3948E1B8D84E54FC6B284E--><AD_MESSAGE>
 <!--0C093B834C3948E1B8D84E54FC6B284E-->  <AD_MESSAGE_ID><![CDATA[0C093B834C3948E1B8D84E54FC6B284E]]></AD_MESSAGE_ID>
 <!--0C093B834C3948E1B8D84E54FC6B284E-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
--- a/src/org/openbravo/erpCommon/ad_actionButton/CreateFrom.java	Thu Sep 20 12:10:09 2012 +0200
+++ b/src/org/openbravo/erpCommon/ad_actionButton/CreateFrom.java	Thu Sep 20 12:39:59 2012 +0200
@@ -1576,9 +1576,9 @@
             BigDecimal taxAmt = ((lineNetAmt.multiply(taxRate)).divide(new BigDecimal("100"), 12,
                 BigDecimal.ROUND_HALF_EVEN)).setScale(curPrecision, BigDecimal.ROUND_HALF_UP);
             try {
-              final String strOrg2 = vars.getGlobalVariable("inpadOrgId", "CreateFrom|adOrgId", "");
+              //final String strOrg2 = vars.getGlobalVariable("inpadOrgId", "CreateFrom|adOrgId", "");
               CreateFromInvoiceData.insert(conn, this, strSequence, strKey, vars.getClient(),
-                  strOrg2, vars.getUser(), data[i].cOrderlineId, data[i].mInoutlineId,
+            		  data[i].adOrgId, vars.getUser(), data[i].cOrderlineId, data[i].mInoutlineId,
                   data[i].description, data[i].mProductId, data[i].cUomId, data[i].id, priceList,
                   priceActual, priceLimit, lineNetAmt.toString(), C_Tax_ID, taxAmt.toPlainString(),
                   data[i].quantityorder, data[i].mProductUomId, data[i].mAttributesetinstanceId,