Deleting a Sales Order with reference to a voided delivery causes SQL error when
authorJoe Hunt <joe.hunt.consulting@gmail.com>
Wed, 21 Apr 2010 08:20:52 +0000 (08:20 +0000)
committerJoe Hunt <joe.hunt.consulting@gmail.com>
Wed, 21 Apr 2010 08:20:52 +0000 (08:20 +0000)
looking at this delivery. Solution, can't delete, but set the deliveries to 0
on the lines.

CHANGELOG.txt
sales/includes/db/sales_order_db.inc

index 3008492a694d05ee36d912a2cecc8ea0b03be500..6e513076780575b30bd644c5038ae4e7401500f7 100644 (file)
@@ -19,6 +19,12 @@ Legend:
 ! -> Note
 $ -> Affected files
 
+21-Apr-2010 Joe Hunt
+# Deleting a Sales Order with reference to a voided delivery causes SQL error when
+  looking at this delivery. Solution, can't delete, but set the deliveries to 0
+  on the lines.
+$ /sales/includes/db/sales_order_db.inc
+
 ------------------------------- Release 2.2.8 ----------------------------------
 18-Apr-2010
 ! Release 2.2.8
index 79d5adc9deff3332e0314106a6eba7aa7ab7ea1c..b12011d447b04390e1a888884c931253810408a5 100644 (file)
@@ -390,7 +390,11 @@ function sales_order_has_deliveries($order_no)
 
        $row = db_fetch_row($result);
 
-       return ($row[0] > 0);
+       if ($row[0] > 0)
+               return true;  // 2010-04-21 added check for eventually voided deliveries, Joe Hunt
+       $sql = "SELECT order_ FROM ".TB_PREF."debtor_trans WHERE type=".ST_CUSTDELIVERY." AND order_=".db_escape($order_no);
+       $result = db_query($sql,"The related delivery notes could not be retreived");
+       return (db_num_rows($result) > 0);      
 }
 
 //----------------------------------------------------------------------------------------