From 2352dbffc168cdbed84db3e31b0afdb1cc9f61df Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 27 Jul 2010 18:33:41 +0000 Subject: [PATCH] Fix: Error in migrate of deliveries --- htdocs/install/mysql/migration/2.8.0-2.9.0.sql | 2 ++ htdocs/install/upgrade2.php | 6 ++++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/htdocs/install/mysql/migration/2.8.0-2.9.0.sql b/htdocs/install/mysql/migration/2.8.0-2.9.0.sql index c67caba575e..fa551045381 100755 --- a/htdocs/install/mysql/migration/2.8.0-2.9.0.sql +++ b/htdocs/install/mysql/migration/2.8.0-2.9.0.sql @@ -240,6 +240,8 @@ ALTER TABLE llx_menu ADD UNIQUE INDEX idx_menu_uk_menu (menu_handler, fk_menu, p UPDATE llx_const SET name = 'MAIN_MODULE_PRODUCT' WHERE name = 'MAIN_MODULE_PRODUIT'; +UPDATE llx_expedition set ref_customer = NULL where ref_customer = ''; + -- Add more predefined action codes -- insert into llx_c_actioncomm (id, code, type, libelle, module) values (30, 'AC_SUP_ORD', 'system', 'Send supplier invoice by email' ,'supplier_order'); insert into llx_c_actioncomm (id, code, type, libelle, module) values (31, 'AC_SUP_INV', 'system', 'Send supplier invoice by email' ,'supplier_invoice'); diff --git a/htdocs/install/upgrade2.php b/htdocs/install/upgrade2.php index e35c37f4901..8407e349f69 100644 --- a/htdocs/install/upgrade2.php +++ b/htdocs/install/upgrade2.php @@ -3104,7 +3104,8 @@ function migrate_shipping_delivery($db,$langs,$conf) } /* - * Migrate shipping ref_customer and date_delivery fields to llx_livraison + * We try to complete field ref_customer and date_delivery that are empty into llx_livraison. + * We set them with value from llx_expedition. */ function migrate_shipping_delivery2($db,$langs,$conf) { @@ -3126,6 +3127,7 @@ function migrate_shipping_delivery2($db,$langs,$conf) $sqlSelect.= " WHERE l.rowid = el.fk_target"; $sqlSelect.= " AND el.targettype = 'delivery'"; $sqlSelect.= " AND e.rowid = el.fk_source AND el.sourcetype = 'shipping'"; + $sqlSelect.= " AND (e.ref_customer IS NOT NULL OR e.date_delivery IS NOT NULL)"; // Useless to process this record if both are null // Add condition to know if we never migrate this record $sqlSelect.= " AND (l.ref_customer IS NULL".($db->type!='pgsql'?" or l.ref_customer = ''":"").")"; $sqlSelect.= " AND (l.date_delivery IS NULL".($db->type!='pgsql'?" or l.date_delivery = ''":"").")"; @@ -3144,7 +3146,7 @@ function migrate_shipping_delivery2($db,$langs,$conf) $sqlUpdate = "UPDATE ".MAIN_DB_PREFIX."livraison SET"; $sqlUpdate.= " ref_customer = '".$obj->ref_customer."',"; - $sqlUpdate.= " date_delivery = '".($obj->date_delivery?$obj->date_delivery:'null')."'"; + $sqlUpdate.= " date_delivery = ".($obj->date_delivery?"'".$obj->date_delivery."'":'null'); $sqlUpdate.= " WHERE rowid = ".$obj->delivery_id; $result=$db->query($sqlUpdate);