Merge
authorJuan Pablo Aroztegi <juanpablo.aroztegi@openbravo.com>
Mon, 08 Mar 2010 23:43:03 +0100
changeset 6643 4c9434ffe345
parent 6642 0a25241e3823 (current diff)
parent 6596 17ddf2c3af51 (diff)
child 6644 30f20d9b6229
Merge
.hgsigs
.hgtags
src-db/database/sourcedata/AD_MODULE.xml
--- a/.hgsigs	Sat Mar 06 10:10:36 2010 +0100
+++ b/.hgsigs	Mon Mar 08 23:43:03 2010 +0100
@@ -11,4 +11,5 @@
 e7c306101389e980c1a1fb9d1bfeb3e200efaa94 0 iEYEABECAAYFAksNhdEACgkQCX/oGf+2qkNCCgCfVvVHzYDUBoPwv3mHqE+dLpz88UsAnRrvpWvUmXozxdaMD0X0IV123bH0
 0b5e5cf1aa6b85df792522ed84d9755a1563c4f6 0 iEYEABECAAYFAktQTfIACgkQCX/oGf+2qkMeKgCgxxmPlv10O2oQEIEF18iBJR5hD4AAn1VYgmnxMZUGQA7WT6/j8PtMV9je
 630f94155c011c18a4bd948239d674953ad729c4 0 iEYEABECAAYFAkthyKQACgkQCX/oGf+2qkOIwgCcCk4MJcMrnHR9WgEGfRx4HoTYfjsAn26YI0m1bCQSlyqmh+gDusmsqrNA
+4a5dd51c34fbbf64e9f933f9b7d54589ef5fb7b9 0 iEYEABECAAYFAkuM+1EACgkQCX/oGf+2qkPHfgCdFKV1PxtXcckQ3R3+kJgXnRFAtgkAoM6eWuR1ZA3nRphHH7sX2SGoufA5
 75b887d57378e59138c0362b928a504db568ed9b 0 iEYEABECAAYFAkuSHAsACgkQCX/oGf+2qkOEpwCeM6aKuQ/VK5ywylW5Jiki2L5YX0UAoPtzt8ELfu+2n0hTB2E36NgVq1IU
--- a/.hgtags	Sat Mar 06 10:10:36 2010 +0100
+++ b/.hgtags	Mon Mar 08 23:43:03 2010 +0100
@@ -21,4 +21,5 @@
 003090f7d33a5d408405addea4c74ca8e1d9f186 2.50MP9
 f873f7f56a657920123211550340ca358e270de7 2.50MP10
 98d31cbff884dd20581e1cafad505ed8f9b33273 2.50MP11
+1a6428c78a5521471084e7b93a42a03a74543495 2.50MP12
 65aa17bbe739f7d3370aba319e68474c2356fdf2 2.50MP13
--- a/build.xml	Sat Mar 06 10:10:36 2010 +0100
+++ b/build.xml	Mon Mar 08 23:43:03 2010 +0100
@@ -540,6 +540,7 @@
 
     <antcall target="import.sample.data" />
     <antcall target="load.logoimages" />
+    <updatesystemstatus v="RB51"/> 
     <ant dir="${base.db}" target="setApplied" inheritAll="true" inheritRefs="true" />
 
     <!--
@@ -558,6 +559,8 @@
     <echo message="applying modules" />    
     <antcall inheritall="true" inheritrefs="true" target="apply.module" />
     <antcall target="import.sample.data" />
+    <updatesystemstatus v="RB51"/>
+    <ant dir="${base.db}" target="setApplied" inheritAll="true" inheritRefs="true" />
   </target>
 
   <target name="create.database" depends="init, core.lib, database.lib">
--- a/config/Openbravo.properties.template	Sat Mar 06 10:10:36 2010 +0100
+++ b/config/Openbravo.properties.template	Mon Mar 08 23:43:03 2010 +0100
@@ -134,7 +134,7 @@
 # wasn't restarted, users will only be able to login in the application 
 # with role System Administrator
 
-safe.mode=false
+safe.mode=true
 
 ##############
 # Hibernate #
--- a/src-db/database/model/functions/C_INVOICE_POST.xml	Sat Mar 06 10:10:36 2010 +0100
+++ b/src-db/database/model/functions/C_INVOICE_POST.xml	Mon Mar 08 23:43:03 2010 +0100
@@ -95,6 +95,7 @@
     v_Currency_ID VARCHAR2(32);
     v_Multiplier NUMBER:=1;
 	v_Amount NUMBER:=0;--CashLine amount
+    v_paymentcheck NUMBER;
     --
     v_RInvoice_ID VARCHAR2(32);
     v_RDocumentNo C_INVOICE.DocumentNo%TYPE;
@@ -1611,6 +1612,8 @@
                 END IF;
                 v_pendingAmount:=v_pendingAmount - v_paymentAmount;
                 Ad_Sequence_Next('C_Debt_Payment', v_Record_ID, v_debtPaymentID) ;
+                v_paymentcheck:=C_Currency_Round((v_paymentamount *v_multiplierarc) -withholdamount *(v_paymentamount *v_multiplierarc / v_grandtotal), v_Currency_ID, NULL);
+                IF(v_paymentcheck <> 0) THEN
                 INSERT
                 INTO C_DEBT_PAYMENT
                   (
@@ -1635,6 +1638,7 @@
                     'N', v_C_Project_Id, 'DE', 'DE', C_Currency_Round(withholdamount *(v_paymentamount *v_multiplierarc / v_grandtotal), v_Currency_ID, NULL),cWithHoldId
                   )
                   ;
+                  END IF;
                 --AL
                 --Looking for autogenerated debt-payments
                 SELECT MAX(c_Debt_Payment_Id), MAX(ad_Org_ID)
--- a/src-db/database/sourcedata/AD_FIELD.xml	Sat Mar 06 10:10:36 2010 +0100
+++ b/src-db/database/sourcedata/AD_FIELD.xml	Mon Mar 08 23:43:03 2010 +0100
@@ -32206,7 +32206,7 @@
 <!--2880-->  <ISDISPLAYED><![CDATA[Y]]></ISDISPLAYED>
 <!--2880-->  <DISPLAYLENGTH><![CDATA[10]]></DISPLAYLENGTH>
 <!--2880-->  <ISREADONLY><![CDATA[N]]></ISREADONLY>
-<!--2880-->  <SEQNO><![CDATA[320]]></SEQNO>
+<!--2880-->  <SEQNO><![CDATA[310]]></SEQNO>
 <!--2880-->  <ISSAMELINE><![CDATA[N]]></ISSAMELINE>
 <!--2880-->  <ISFIELDONLY><![CDATA[N]]></ISFIELDONLY>
 <!--2880-->  <ISENCRYPTED><![CDATA[N]]></ISENCRYPTED>
@@ -33841,7 +33841,7 @@
 <!--2995-->  <ISDISPLAYED><![CDATA[Y]]></ISDISPLAYED>
 <!--2995-->  <DISPLAYLENGTH><![CDATA[10]]></DISPLAYLENGTH>
 <!--2995-->  <ISREADONLY><![CDATA[N]]></ISREADONLY>
-<!--2995-->  <SEQNO><![CDATA[210]]></SEQNO>
+<!--2995-->  <SEQNO><![CDATA[200]]></SEQNO>
 <!--2995-->  <ISSAMELINE><![CDATA[N]]></ISSAMELINE>
 <!--2995-->  <ISFIELDONLY><![CDATA[N]]></ISFIELDONLY>
 <!--2995-->  <ISENCRYPTED><![CDATA[N]]></ISENCRYPTED>
@@ -39223,7 +39223,7 @@
 <!--3370-->  <ISDISPLAYED><![CDATA[Y]]></ISDISPLAYED>
 <!--3370-->  <DISPLAYLENGTH><![CDATA[10]]></DISPLAYLENGTH>
 <!--3370-->  <ISREADONLY><![CDATA[N]]></ISREADONLY>
-<!--3370-->  <SEQNO><![CDATA[200]]></SEQNO>
+<!--3370-->  <SEQNO><![CDATA[190]]></SEQNO>
 <!--3370-->  <ISSAMELINE><![CDATA[N]]></ISSAMELINE>
 <!--3370-->  <ISFIELDONLY><![CDATA[N]]></ISFIELDONLY>
 <!--3370-->  <ISENCRYPTED><![CDATA[N]]></ISENCRYPTED>
@@ -40232,7 +40232,7 @@
 <!--3416-->  <ISDISPLAYED><![CDATA[Y]]></ISDISPLAYED>
 <!--3416-->  <DISPLAYLENGTH><![CDATA[10]]></DISPLAYLENGTH>
 <!--3416-->  <ISREADONLY><![CDATA[N]]></ISREADONLY>
-<!--3416-->  <SEQNO><![CDATA[310]]></SEQNO>
+<!--3416-->  <SEQNO><![CDATA[300]]></SEQNO>
 <!--3416-->  <ISSAMELINE><![CDATA[N]]></ISSAMELINE>
 <!--3416-->  <ISFIELDONLY><![CDATA[N]]></ISFIELDONLY>
 <!--3416-->  <ISENCRYPTED><![CDATA[N]]></ISENCRYPTED>
@@ -191473,10 +191473,9 @@
 <!--61B11EA6D16C4948910D06E49A728085-->  <AD_TAB_ID><![CDATA[293]]></AD_TAB_ID>
 <!--61B11EA6D16C4948910D06E49A728085-->  <AD_COLUMN_ID><![CDATA[7E011D1981B2E366E040007F01013030]]></AD_COLUMN_ID>
 <!--61B11EA6D16C4948910D06E49A728085-->  <AD_FIELDGROUP_ID><![CDATA[103]]></AD_FIELDGROUP_ID>
-<!--61B11EA6D16C4948910D06E49A728085-->  <ISDISPLAYED><![CDATA[Y]]></ISDISPLAYED>
+<!--61B11EA6D16C4948910D06E49A728085-->  <ISDISPLAYED><![CDATA[N]]></ISDISPLAYED>
 <!--61B11EA6D16C4948910D06E49A728085-->  <DISPLAYLENGTH><![CDATA[1]]></DISPLAYLENGTH>
 <!--61B11EA6D16C4948910D06E49A728085-->  <ISREADONLY><![CDATA[N]]></ISREADONLY>
-<!--61B11EA6D16C4948910D06E49A728085-->  <SEQNO><![CDATA[300]]></SEQNO>
 <!--61B11EA6D16C4948910D06E49A728085-->  <ISSAMELINE><![CDATA[N]]></ISSAMELINE>
 <!--61B11EA6D16C4948910D06E49A728085-->  <ISFIELDONLY><![CDATA[N]]></ISFIELDONLY>
 <!--61B11EA6D16C4948910D06E49A728085-->  <ISENCRYPTED><![CDATA[N]]></ISENCRYPTED>
@@ -191885,10 +191884,9 @@
 <!--6C50F0BA9E0C43F0813C0D2F9E0D70A8-->  <AD_TAB_ID><![CDATA[291]]></AD_TAB_ID>
 <!--6C50F0BA9E0C43F0813C0D2F9E0D70A8-->  <AD_COLUMN_ID><![CDATA[7E011D1981B1E366E040007F01013030]]></AD_COLUMN_ID>
 <!--6C50F0BA9E0C43F0813C0D2F9E0D70A8-->  <AD_FIELDGROUP_ID><![CDATA[103]]></AD_FIELDGROUP_ID>
-<!--6C50F0BA9E0C43F0813C0D2F9E0D70A8-->  <ISDISPLAYED><![CDATA[Y]]></ISDISPLAYED>
+<!--6C50F0BA9E0C43F0813C0D2F9E0D70A8-->  <ISDISPLAYED><![CDATA[N]]></ISDISPLAYED>
 <!--6C50F0BA9E0C43F0813C0D2F9E0D70A8-->  <DISPLAYLENGTH><![CDATA[1]]></DISPLAYLENGTH>
 <!--6C50F0BA9E0C43F0813C0D2F9E0D70A8-->  <ISREADONLY><![CDATA[N]]></ISREADONLY>
-<!--6C50F0BA9E0C43F0813C0D2F9E0D70A8-->  <SEQNO><![CDATA[190]]></SEQNO>
 <!--6C50F0BA9E0C43F0813C0D2F9E0D70A8-->  <ISSAMELINE><![CDATA[N]]></ISSAMELINE>
 <!--6C50F0BA9E0C43F0813C0D2F9E0D70A8-->  <ISFIELDONLY><![CDATA[N]]></ISFIELDONLY>
 <!--6C50F0BA9E0C43F0813C0D2F9E0D70A8-->  <ISENCRYPTED><![CDATA[N]]></ISENCRYPTED>
@@ -193178,7 +193176,7 @@
 <!--7E35F16BB0F8C186E040007F010014C7-->  <DISPLAYLOGIC><![CDATA[@UsesAlternate@='Y']]></DISPLAYLOGIC>
 <!--7E35F16BB0F8C186E040007F010014C7-->  <DISPLAYLENGTH><![CDATA[12]]></DISPLAYLENGTH>
 <!--7E35F16BB0F8C186E040007F010014C7-->  <ISREADONLY><![CDATA[N]]></ISREADONLY>
-<!--7E35F16BB0F8C186E040007F010014C7-->  <SEQNO><![CDATA[220]]></SEQNO>
+<!--7E35F16BB0F8C186E040007F010014C7-->  <SEQNO><![CDATA[210]]></SEQNO>
 <!--7E35F16BB0F8C186E040007F010014C7-->  <ISSAMELINE><![CDATA[Y]]></ISSAMELINE>
 <!--7E35F16BB0F8C186E040007F010014C7-->  <ISFIELDONLY><![CDATA[N]]></ISFIELDONLY>
 <!--7E35F16BB0F8C186E040007F010014C7-->  <ISENCRYPTED><![CDATA[N]]></ISENCRYPTED>
@@ -193202,7 +193200,7 @@
 <!--7E35F16BB0F9C186E040007F010014C7-->  <DISPLAYLOGIC><![CDATA[@UsesAlternate@='Y']]></DISPLAYLOGIC>
 <!--7E35F16BB0F9C186E040007F010014C7-->  <DISPLAYLENGTH><![CDATA[12]]></DISPLAYLENGTH>
 <!--7E35F16BB0F9C186E040007F010014C7-->  <ISREADONLY><![CDATA[N]]></ISREADONLY>
-<!--7E35F16BB0F9C186E040007F010014C7-->  <SEQNO><![CDATA[210]]></SEQNO>
+<!--7E35F16BB0F9C186E040007F010014C7-->  <SEQNO><![CDATA[200]]></SEQNO>
 <!--7E35F16BB0F9C186E040007F010014C7-->  <ISSAMELINE><![CDATA[Y]]></ISSAMELINE>
 <!--7E35F16BB0F9C186E040007F010014C7-->  <ISFIELDONLY><![CDATA[N]]></ISFIELDONLY>
 <!--7E35F16BB0F9C186E040007F010014C7-->  <ISENCRYPTED><![CDATA[N]]></ISENCRYPTED>
@@ -193314,7 +193312,7 @@
 <!--7E37B8136CC375EFE040007F0100360F-->  <DISPLAYLOGIC><![CDATA[@UsesAlternate@='Y']]></DISPLAYLOGIC>
 <!--7E37B8136CC375EFE040007F0100360F-->  <DISPLAYLENGTH><![CDATA[12]]></DISPLAYLENGTH>
 <!--7E37B8136CC375EFE040007F0100360F-->  <ISREADONLY><![CDATA[N]]></ISREADONLY>
-<!--7E37B8136CC375EFE040007F0100360F-->  <SEQNO><![CDATA[330]]></SEQNO>
+<!--7E37B8136CC375EFE040007F0100360F-->  <SEQNO><![CDATA[320]]></SEQNO>
 <!--7E37B8136CC375EFE040007F0100360F-->  <ISSAMELINE><![CDATA[Y]]></ISSAMELINE>
 <!--7E37B8136CC375EFE040007F0100360F-->  <ISFIELDONLY><![CDATA[N]]></ISFIELDONLY>
 <!--7E37B8136CC375EFE040007F0100360F-->  <ISENCRYPTED><![CDATA[N]]></ISENCRYPTED>
@@ -193357,7 +193355,7 @@
 <!--7E37B8136CC575EFE040007F0100360F-->  <DISPLAYLOGIC><![CDATA[@UsesAlternate@='Y']]></DISPLAYLOGIC>
 <!--7E37B8136CC575EFE040007F0100360F-->  <DISPLAYLENGTH><![CDATA[12]]></DISPLAYLENGTH>
 <!--7E37B8136CC575EFE040007F0100360F-->  <ISREADONLY><![CDATA[N]]></ISREADONLY>
-<!--7E37B8136CC575EFE040007F0100360F-->  <SEQNO><![CDATA[320]]></SEQNO>
+<!--7E37B8136CC575EFE040007F0100360F-->  <SEQNO><![CDATA[310]]></SEQNO>
 <!--7E37B8136CC575EFE040007F0100360F-->  <ISSAMELINE><![CDATA[Y]]></ISSAMELINE>
 <!--7E37B8136CC575EFE040007F0100360F-->  <ISFIELDONLY><![CDATA[N]]></ISFIELDONLY>
 <!--7E37B8136CC575EFE040007F0100360F-->  <ISENCRYPTED><![CDATA[N]]></ISENCRYPTED>
@@ -194438,10 +194436,9 @@
 <!--8329181A30D547FBB01E0CD7013069E6-->  <AD_TAB_ID><![CDATA[187]]></AD_TAB_ID>
 <!--8329181A30D547FBB01E0CD7013069E6-->  <AD_COLUMN_ID><![CDATA[7E011D1981B2E366E040007F01013030]]></AD_COLUMN_ID>
 <!--8329181A30D547FBB01E0CD7013069E6-->  <AD_FIELDGROUP_ID><![CDATA[103]]></AD_FIELDGROUP_ID>
-<!--8329181A30D547FBB01E0CD7013069E6-->  <ISDISPLAYED><![CDATA[Y]]></ISDISPLAYED>
+<!--8329181A30D547FBB01E0CD7013069E6-->  <ISDISPLAYED><![CDATA[N]]></ISDISPLAYED>
 <!--8329181A30D547FBB01E0CD7013069E6-->  <DISPLAYLENGTH><![CDATA[1]]></DISPLAYLENGTH>
 <!--8329181A30D547FBB01E0CD7013069E6-->  <ISREADONLY><![CDATA[N]]></ISREADONLY>
-<!--8329181A30D547FBB01E0CD7013069E6-->  <SEQNO><![CDATA[310]]></SEQNO>
 <!--8329181A30D547FBB01E0CD7013069E6-->  <ISSAMELINE><![CDATA[N]]></ISSAMELINE>
 <!--8329181A30D547FBB01E0CD7013069E6-->  <ISFIELDONLY><![CDATA[N]]></ISFIELDONLY>
 <!--8329181A30D547FBB01E0CD7013069E6-->  <ISENCRYPTED><![CDATA[N]]></ISENCRYPTED>
@@ -194507,10 +194504,9 @@
 <!--86E59478FE6B4DC68BA401230C3DFC17-->  <AD_TAB_ID><![CDATA[270]]></AD_TAB_ID>
 <!--86E59478FE6B4DC68BA401230C3DFC17-->  <AD_COLUMN_ID><![CDATA[7E011D1981B1E366E040007F01013030]]></AD_COLUMN_ID>
 <!--86E59478FE6B4DC68BA401230C3DFC17-->  <AD_FIELDGROUP_ID><![CDATA[103]]></AD_FIELDGROUP_ID>
-<!--86E59478FE6B4DC68BA401230C3DFC17-->  <ISDISPLAYED><![CDATA[Y]]></ISDISPLAYED>
+<!--86E59478FE6B4DC68BA401230C3DFC17-->  <ISDISPLAYED><![CDATA[N]]></ISDISPLAYED>
 <!--86E59478FE6B4DC68BA401230C3DFC17-->  <DISPLAYLENGTH><![CDATA[1]]></DISPLAYLENGTH>
 <!--86E59478FE6B4DC68BA401230C3DFC17-->  <ISREADONLY><![CDATA[N]]></ISREADONLY>
-<!--86E59478FE6B4DC68BA401230C3DFC17-->  <SEQNO><![CDATA[200]]></SEQNO>
 <!--86E59478FE6B4DC68BA401230C3DFC17-->  <ISSAMELINE><![CDATA[N]]></ISSAMELINE>
 <!--86E59478FE6B4DC68BA401230C3DFC17-->  <ISFIELDONLY><![CDATA[N]]></ISFIELDONLY>
 <!--86E59478FE6B4DC68BA401230C3DFC17-->  <ISENCRYPTED><![CDATA[N]]></ISENCRYPTED>
--- a/src-db/database/sourcedata/AD_MODULE.xml	Sat Mar 06 10:10:36 2010 +0100
+++ b/src-db/database/sourcedata/AD_MODULE.xml	Mon Mar 08 23:43:03 2010 +0100
@@ -21,7 +21,7 @@
 <!--0-->  <HASCHARTOFACCOUNTS><![CDATA[N]]></HASCHARTOFACCOUNTS>
 <!--0-->  <ISTRANSLATIONMODULE><![CDATA[N]]></ISTRANSLATIONMODULE>
 <!--0-->  <HASREFERENCEDATA><![CDATA[Y]]></HASREFERENCEDATA>
-<!--0-->  <VERSION_LABEL><![CDATA[MP13]]></VERSION_LABEL>
+<!--0-->  <VERSION_LABEL><![CDATA[CI]]></VERSION_LABEL>
 <!--0-->  <ISCOMMERCIAL><![CDATA[N]]></ISCOMMERCIAL>
 <!--0--></AD_MODULE>
 
--- a/src/build.xml	Sat Mar 06 10:10:36 2010 +0100
+++ b/src/build.xml	Mon Mar 08 23:43:03 2010 +0100
@@ -804,6 +804,7 @@
       </zipfileset>
       <classes dir="${build}" />
     </war>
+    <updatesystemstatus v="RB51"/>
   </target>
 
   <target name="generate-wsdd">
--- a/src/org/openbravo/erpCommon/ad_forms/DocInOut_data.xsql	Sat Mar 06 10:10:36 2010 +0100
+++ b/src/org/openbravo/erpCommon/ad_forms/DocInOut_data.xsql	Mon Mar 08 23:43:03 2010 +0100
@@ -71,11 +71,13 @@
   <SqlMethod name="selectClientCurrencyPrecission" type="preparedStatement" return="string">
     <SqlMethodComment></SqlMethodComment>
     <Sql>
+      <![CDATA[
       select stdprecision 
       from c_currency cu, ad_client cl
        where cu.c_currency_id=cl.c_currency_id
          and cl.ad_client_id=?
+     ]]>
     </Sql>
     <Parameter name="adClientId"/>
   </SqlMethod>
-</SqlClass>
\ No newline at end of file
+</SqlClass>
--- a/src/org/openbravo/erpCommon/ad_forms/DocMatchInv.java	Sat Mar 06 10:10:36 2010 +0100
+++ b/src/org/openbravo/erpCommon/ad_forms/DocMatchInv.java	Mon Mar 08 23:43:03 2010 +0100
@@ -138,7 +138,7 @@
 
     FieldProvider[] data = getObjectFieldProvider();
     BigDecimal bdCost = new BigDecimal(DocMatchInvData.selectProductAverageCost(conn, data[0]
-        .getField("M_Product_Id"), data[0].getField("DateTrx")));
+        .getField("M_Product_Id"), data[0].getField("DateAcct")));
     String strScale = DocMatchInvData.selectClientCurrencyPrecission(conn, vars.getClient());
     bdCost = bdCost.multiply(new BigDecimal(data[0].getField("Qty"))).setScale(
         new Integer(strScale), RoundingMode.HALF_UP);
--- a/src/org/openbravo/erpCommon/ad_forms/DocMatchInv_data.xsql	Sat Mar 06 10:10:36 2010 +0100
+++ b/src/org/openbravo/erpCommon/ad_forms/DocMatchInv_data.xsql	Mon Mar 08 23:43:03 2010 +0100
@@ -37,10 +37,12 @@
     <![CDATA[
       SELECT M.M_MATCHINV_ID, M.AD_CLIENT_ID, M.AD_ORG_ID, M.ISACTIVE, M.CREATED, M.CREATEDBY, M.UPDATED,
         M.UPDATEDBY, M.M_INOUTLINE_ID, M.C_INVOICELINE_ID, M.M_PRODUCT_ID, M.DATETRX, M.QTY, M.PROCESSING,
-        M.PROCESSED, M.POSTED, M.DATETRX AS DATEACCT, M.DATETRX AS DATEDOC, I.C_BPARTNER_ID
-      FROM M_MATCHINV M, C_INVOICELINE IL, C_INVOICE I
+        M.PROCESSED, M.POSTED, M.DATETRX AS DATEACCT, M.DATETRX AS DATEDOC, I.C_BPARTNER_ID, IO.DATEACCT
+      FROM M_MATCHINV M, C_INVOICELINE IL, C_INVOICE I, M_INOUTLINE IOL, M_INOUT IO
       WHERE IL.C_INVOICELINE_ID = M.C_INVOICELINE_ID
         AND IL.C_INVOICE_ID = I.C_INVOICE_ID
+        AND IOL.M_INOUTLINE_ID = M.M_INOUTLINE_ID
+        AND IO.M_INOUT_ID = IOL.M_INOUT_ID
         AND M.AD_Client_ID=?
         AND M.M_MATCHINV_ID=?
     ]]>
--- a/src/org/openbravo/erpCommon/ad_forms/MaterialReceiptPending_data.xsql	Sat Mar 06 10:10:36 2010 +0100
+++ b/src/org/openbravo/erpCommon/ad_forms/MaterialReceiptPending_data.xsql	Mon Mar 08 23:43:03 2010 +0100
@@ -65,7 +65,7 @@
       C_BPARTNER.NAME, C_ORDERLINE.M_PRODUCT_ID, M_ATTRIBUTESETINSTANCE.DESCRIPTION, C_ORDERLINE.QTYORDERED
       ORDER BY PARTNER_NAME, DOCUMENTNO, DATEORDERED) A
       WHERE QTYORDERED <>0
-      ORDER BY C_BPARTNER_ID, ID
+      ORDER BY C_BPARTNER_ID
       ]]></Sql>
 	<Field name="rownum" value="count"/>
     <Parameter name="dateFormat"/>
--- a/src/org/openbravo/erpCommon/obps/ActivationKey.java	Sat Mar 06 10:10:36 2010 +0100
+++ b/src/org/openbravo/erpCommon/obps/ActivationKey.java	Mon Mar 08 23:43:03 2010 +0100
@@ -391,9 +391,12 @@
     Date lastValidPingTime = new Date(cal.getTimeInMillis());
 
     OBCriteria<Session> obCriteria = OBDal.getInstance().createCriteria(Session.class);
-    obCriteria.add(Expression.eq(Session.PROPERTY_SESSIONACTIVE, true));
-    obCriteria.add(Expression.isNotNull(Session.PROPERTY_LASTPING));
-    obCriteria.add(Expression.lt(Session.PROPERTY_LASTPING, lastValidPingTime));
+
+    // sesion_active='Y' and (lastPing is null or lastPing<lastValidPing)
+    obCriteria.add(Expression.and(Expression.eq(Session.PROPERTY_SESSIONACTIVE, true), Expression
+        .or(Expression.isNull(Session.PROPERTY_LASTPING), Expression.lt(Session.PROPERTY_LASTPING,
+            lastValidPingTime))));
+
     boolean sessionDeactivated = false;
     for (Session expiredSession : obCriteria.list()) {
       expiredSession.setSessionActive(false);