src/org/openbravo/erpCommon/ad_actionButton/CreateFrom_Invoice_data.xsql
changeset 15683 a77ef04bc81c
parent 15164 30a7643fa5b0
child 15687 0f4211de14eb
--- a/src/org/openbravo/erpCommon/ad_actionButton/CreateFrom_Invoice_data.xsql	Tue Feb 28 16:04:56 2012 +0000
+++ b/src/org/openbravo/erpCommon/ad_actionButton/CreateFrom_Invoice_data.xsql	Fri Feb 24 08:49:44 2012 +0100
@@ -363,12 +363,12 @@
         WHERE o.C_ORDER_ID = s.C_ORDER_ID
         AND o.C_ORDER_ID = ic.C_ORDER_ID
         AND ic.term = 'N')
-        AND EXISTS (SELECT 1
+        AND NOT EXISTS (SELECT 1
         FROM C_ORDER o , C_ORDERLINE ol
         WHERE o.C_ORDER_ID = s.C_ORDER_ID
         AND o.C_ORDER_ID = ol.C_ORDER_ID
         GROUP BY o.INVOICERULE
-        HAVING o.INVOICERULE <> 'O' OR (SUM(ol.qtyordered) = SUM(ol.qtydelivered)))
+        HAVING (o.INVOICERULE = 'O' AND SUM(ol.qtyordered) <> SUM(ol.qtydelivered)))
         ORDER BY NAME
       ]]>
     </Sql>