diff --git a/htdocs/install/upgrade2.php b/htdocs/install/upgrade2.php
index ccb41d7db9d..2e0cef13faa 100644
--- a/htdocs/install/upgrade2.php
+++ b/htdocs/install/upgrade2.php
@@ -180,6 +180,10 @@ if (isset($_POST['action']) && $_POST['action'] == 'upgrade')
// Script pour V2.2 -> V2.4
migrate_commande_expedition($db,$langs,$conf);
+
+ migrate_commande_livraison($db,$langs,$conf);
+
+ migrate_detail_livraison($db,$langs,$conf);
migrate_module_menus($db,$langs,$conf);
@@ -1550,6 +1554,196 @@ function migrate_commande_expedition($db,$langs,$conf)
}
}
+/*
+ * Correspondance des livraisons et des commandes clients dans la table llx_co_liv
+ */
+function migrate_commande_livraison($db,$langs,$conf)
+{
+ if ($conf->livraison->enabled)
+ {
+ print '
';
+
+ print ' ';
+ print ''.$langs->trans('MigrationDeliveryOrderMatching')." \n";
+
+ $result = $db->DDLDescTable(MAIN_DB_PREFIX."livraison","fk_commande");
+ $obj = $db->fetch_object($result);
+ if ($obj)
+ {
+ $sql = "SELECT l.rowid, l.fk_commande";
+ $sql.= ", c.ref_client, c.date_livraison";
+ $sql.= " FROM ".MAIN_DB_PREFIX."livraison as l, ".MAIN_DB_PREFIX."commande as c";
+ $sql.= " WHERE c.rowid = l.fk_commande";
+ $resql = $db->query($sql);
+ if ($resql)
+ {
+ $i = 0;
+ $error = 0;
+ $num = $db->num_rows($resql);
+
+ if ($num)
+ {
+ $db->begin();
+
+ while ($i < $num)
+ {
+ $obj = $db->fetch_object($resql);
+
+ $sql = "INSERT INTO ".MAIN_DB_PREFIX."co_liv (fk_livraison,fk_commande)";
+ $sql.= " VALUES (".$obj->rowid.",".$obj->fk_commande.")";
+ $resql2=$db->query($sql);
+
+ if ($resql2)
+ {
+ $sqlu = "UPDATE ".MAIN_DB_PREFIX."livraison SET";
+ $sqlu.= "ref_client = '".$obj->ref_client."'";
+ $sqlu.= "date_livraison = '".$obj->date_livraison."'";
+ $sqlu.= " WHERE rowid = ".$obj->rowid;
+ $resql3=$db->query($sqlu);
+ if (!$resql3)
+ {
+ $error++;
+ dolibarr_print_error($db);
+ }
+ }
+ else
+ {
+ $error++;
+ dolibarr_print_error($db);
+ }
+ print ". ";
+ $i++;
+ }
+ if ($error == 0)
+ {
+ $db->commit();
+ $sql = "ALTER TABLE ".MAIN_DB_PREFIX."livraison DROP COLUMN fk_commande";
+ $db->query($sql);
+ }
+ else
+ {
+ $db->rollback();
+ }
+ }
+ }
+ else
+ {
+ dolibarr_print_error($db);
+ }
+ }
+ else
+ {
+ print $langs->trans('AlreadyDone')." \n";
+ }
+ print ' |
';
+ }
+}
+
+/*
+ * Migration des détails commandes dans les détails livraisons
+ */
+function migrate_detail_livraison($db,$langs,$conf)
+{
+ if ($conf->livraison->enabled)
+ {
+ print '';
+
+ print ' ';
+ print ''.$langs->trans('MigrationDeliveryDetail')." \n";
+
+ $result = $db->DDLDescTable(MAIN_DB_PREFIX."livraisondet","fk_commande_ligne");
+ $obj = $db->fetch_object($result);
+ if ($obj)
+ {
+ $sql = "SELECT cd.rowid, cd.fk_product, cd.description, cd.subprice, cd.total_ht";
+ $sql.= ", ld.fk_livraison";
+ $sql.= " FROM ".MAIN_DB_PREFIX."commandedet as cd, ".MAIN_DB_PREFIX."livraisondet as ld";
+ $sql.= " WHERE ld.fk_commande_ligne = cd.rowid";
+ $resql = $db->query($sql);
+ if ($resql)
+ {
+ $i = 0;
+ $error = 0;
+ $num = $db->num_rows($resql);
+
+ if ($num)
+ {
+ $db->begin();
+
+ while ($i < $num)
+ {
+ $obj = $db->fetch_object($resql);
+
+ $sql = "UPDATE ".MAIN_DB_PREFIX."livraisondet SET";
+ $sql.= " fk_product=".$obj->fk_product;
+ $sql.= ",description='".$obj->description."'";
+ $sql.= ",subprice='".$obj->subprice."'";
+ $sql.= ",total_ht='".$obj->total_ht."'";
+ $sql.= " WHERE fk_commande_ligne = ".$obj->rowid;
+ $resql2=$db->query($sql);
+
+ if ($resql2)
+ {
+ $sql = "SELECT l.total_ht";
+ $sql.= " FROM ".MAIN_DB_PREFIX."livraison as l";
+ $sql.= "WHERE rowid = ".$obj->fk_livraison;
+ $resql3=$db->query($sql);
+
+ if ($resql3)
+ {
+ $obju = $db->fetch_object($resql3);
+ $total_ht = $obju->total_ht + $obj->total_ht;
+
+ $sqlu = "UPDATE ".MAIN_DB_PREFIX."livraison SET";
+ $sqlu.= " total_ht='".$total_ht."'";
+ $sqlu.= " WHERE rowid=".$obj->fk_livraison;
+ $resql4=$db->query($sqlu);
+ if (!$resql4)
+ {
+ $error++;
+ dolibarr_print_error($db);
+ }
+ }
+ else
+ {
+ $error++;
+ dolibarr_print_error($db);
+ }
+ }
+ else
+ {
+ $error++;
+ dolibarr_print_error($db);
+ }
+ print ". ";
+ $i++;
+ }
+
+ if ($error == 0)
+ {
+ $db->commit();
+ $sql = "ALTER TABLE ".MAIN_DB_PREFIX."livraisondet DROP COLUMN fk_commande_ligne";
+ $db->query($sql);
+ }
+ else
+ {
+ $db->rollback();
+ }
+ }
+ }
+ else
+ {
+ dolibarr_print_error($db);
+ }
+ }
+ else
+ {
+ print $langs->trans('AlreadyDone')." \n";
+ }
+ print ' |
';
+ }
+}
+
/* A faire egalement: Modif statut paye et fk_facture des factures payés completement
On recherche facture incorrecte:
diff --git a/htdocs/livraison/livraison.class.php b/htdocs/livraison/livraison.class.php
index b597ff7c261..6ddc836c892 100644
--- a/htdocs/livraison/livraison.class.php
+++ b/htdocs/livraison/livraison.class.php
@@ -43,7 +43,8 @@ class Livraison extends CommonObject
var $id;
var $brouillon;
- var $commande_id;
+ var $origin;
+ var $origin_id;
/**
@@ -423,7 +424,7 @@ class Livraison extends CommonObject
for ($i = 0 ; $i < sizeof($expedition->lignes) ; $i++)
{
$LivraisonLigne = new LivraisonLigne($this->db);
- $LivraisonLigne->commande_ligne_id = $expedition->lignes[$i]->order_line_id;
+ $LivraisonLigne->origin_ligne_id = $expedition->lignes[$i]->origin_line_id;
$LivraisonLigne->libelle = $expedition->lignes[$i]->libelle;
$LivraisonLigne->description = $expedition->lignes[$i]->product_desc;
$LivraisonLigne->qty = $expedition->lignes[$i]->qty_expedie;
@@ -432,7 +433,8 @@ class Livraison extends CommonObject
$this->lignes[$i] = $LivraisonLigne;
}
- $this->commande_id = $expedition->commande_id;
+ $this->origin = $expedition->origin;
+ $this->origin_id = $expedition->origin_id;
$this->note = $expedition->note;
$this->projetid = $expedition->projetidp;
$this->date_livraison = $expedition->date_livraison;
diff --git a/mysql/migration/2.2.0-2.4.0.sql b/mysql/migration/2.2.0-2.4.0.sql
index 5db5ca9183f..44a3c282d18 100644
--- a/mysql/migration/2.2.0-2.4.0.sql
+++ b/mysql/migration/2.2.0-2.4.0.sql
@@ -62,17 +62,19 @@ create table llx_co_exp
-- V4 ALTER TABLE llx_expeditiondet DROP INDEX fk_commande_ligne;
alter table llx_expedition add column fk_soc integer NOT NULL after ref;
-alter table llx_expedition add column fk_adresse_livraison integer after date_expedition;
+alter table llx_expedition add column fk_adresse_livraison integer DEFAULT NULL after date_expedition;
-- V4.1 UPDATE llx_expedition as e SET e.fk_soc = (SELECT c.fk_soc FROM llx_commande AS c WHERE e.fk_commande = c.rowid);
-- V4.1 UPDATE llx_expedition as e SET e.fk_adresse_livraison = (SELECT c.fk_adresse_livraison FROM llx_commande AS c WHERE e.fk_commande = c.rowid);
ALTER TABLE llx_expedition ADD INDEX idx_expedition_fk_soc (fk_soc);
ALTER TABLE llx_expedition ADD INDEX idx_expedition_fk_user_author (fk_user_author);
ALTER TABLE llx_expedition ADD INDEX idx_expedition_fk_user_valid (fk_user_valid);
+ALTER TABLE llx_expedition ADD INDEX idx_expedition_fk_adresse_livraison (fk_adresse_livraison);
ALTER TABLE llx_expedition ADD INDEX idx_expedition_fk_expedition_methode (fk_expedition_methode);
-- V4 ALTER TABLE llx_expedition ADD CONSTRAINT fk_expedition_fk_soc FOREIGN KEY (fk_soc) REFERENCES llx_societe (rowid);
-- V4 ALTER TABLE llx_expedition ADD CONSTRAINT fk_expedition_fk_user_author FOREIGN KEY (fk_user_author) REFERENCES llx_user (rowid);
-- V4 ALTER TABLE llx_expedition ADD CONSTRAINT fk_expedition_fk_user_valid FOREIGN KEY (fk_user_valid) REFERENCES llx_user (rowid);
+-- V4 ALTER TABLE llx_expedition ADD CONSTRAINT fk_expedition_fk_adresse_livraison FOREIGN KEY (fk_adresse_livraison) REFERENCES llx_societe_adresse_livraison (rowid);
-- V4 ALTER TABLE llx_expedition ADD CONSTRAINT fk_expedition_fk_expedition_methode FOREIGN KEY (fk_expedition_methode) REFERENCES llx_expedition_methode (rowid);
ALTER TABLE llx_expedition ADD UNIQUE INDEX idx_expedition_uk_ref (ref);
@@ -86,3 +88,46 @@ ALTER TABLE llx_expeditiondet ADD INDEX idx_expeditiondet_fk_expedition (fk_expe
ALTER TABLE llx_expeditiondet ADD INDEX idx_expeditiondet_fk_entrepot (fk_entrepot);
-- V4 ALTER TABLE llx_expeditiondet ADD CONSTRAINT fk_expeditiondet_fk_expedition FOREIGN KEY (fk_expedition) REFERENCES llx_expedition (rowid);
-- V4 ALTER TABLE llx_expeditiondet ADD CONSTRAINT fk_expeditiondet_fk_entrepot FOREIGN KEY (fk_entrepot) REFERENCES llx_entrepot (rowid);
+
+-- Modification livraison
+create table llx_co_liv
+(
+ rowid integer AUTO_INCREMENT PRIMARY KEY,
+ fk_commande integer NOT NULL,
+ fk_livraison integer NOT NULL,
+
+ key(fk_commande),
+ key(fk_livraison)
+)type=innodb;
+
+-- V4 ALTER TABLE llx_livraison DROP INDEX fk_commande;
+-- V4 ALTER TABLE llx_livraison DROP INDEX ref;
+-- V4 ALTER TABLE llx_livraisondet DROP INDEX fk_livraison;
+-- V4 ALTER TABLE llx_livraisondet DROP INDEX fk_commande_ligne;
+ALTER TABLE llx_livraison DROP COLUMN total_ttc;
+
+ALTER TABLE llx_livraison MODIFY total_ht double(24,8) DEFAULT 0;
+ALTER TABLE llx_livraison MODIFY fk_adresse_livraison integer DEFAULT NULL;
+alter table llx_livraison add column ref_client varchar(30) after ref;
+alter table llx_livraison add column fk_soc integer NOT NULL after ref_client;
+UPDATE llx_livraison SET fk_adresse_livraison = NULL WHERE fk_adresse_livraison = 0;
+-- V4.1 UPDATE llx_livraison as l SET l.fk_soc = (SELECT c.fk_soc FROM llx_commande AS c WHERE l.fk_commande = c.rowid);
+
+ALTER TABLE llx_livraison ADD INDEX idx_livraison_fk_soc (fk_soc);
+ALTER TABLE llx_livraison ADD INDEX idx_livraison_fk_user_author (fk_user_author);
+ALTER TABLE llx_livraison ADD INDEX idx_livraison_fk_user_valid (fk_user_valid);
+ALTER TABLE llx_livraison ADD INDEX idx_livraison_fk_adresse_livraison (fk_adresse_livraison);
+-- V4 ALTER TABLE llx_livraison ADD CONSTRAINT fk_livraison_fk_soc FOREIGN KEY (fk_soc) REFERENCES llx_societe (rowid);
+-- V4 ALTER TABLE llx_livraison ADD CONSTRAINT fk_livraison_fk_user_author FOREIGN KEY (fk_user_author) REFERENCES llx_user (rowid);
+-- V4 ALTER TABLE llx_livraison ADD CONSTRAINT fk_livraison_fk_user_valid FOREIGN KEY (fk_user_valid) REFERENCES llx_user (rowid);
+-- V4 ALTER TABLE llx_livraison ADD CONSTRAINT fk_livraison_fk_adresse_livraison FOREIGN KEY (fk_adresse_livraison) REFERENCES llx_societe_adresse_livraison (rowid);
+ALTER TABLE llx_livraison ADD UNIQUE INDEX idx_expedition_uk_ref (ref);
+
+alter table llx_livraisondet add column fk_product integer after fk_livraison;
+alter table llx_livraisondet add column description text after fk_product;
+alter table llx_livraisondet add column subprice double(24,8) DEFAULT 0 after qty;
+alter table llx_livraisondet add column total_ht double(24,8) DEFAULT 0 after subprice;
+alter table llx_livraisondet add column rang integer DEFAULT 0 after total_ht;
+
+ALTER TABLE llx_livraisondet ADD INDEX idx_livraisondet_fk_expedition (fk_livraison);
+-- V4 ALTER TABLE llx_livraisondet ADD CONSTRAINT fk_livraisondet_fk_livraison FOREIGN KEY (fk_livraison) REFERENCES llx_livraison (rowid);
\ No newline at end of file
diff --git a/mysql/tables/llx_co_liv.sql b/mysql/tables/llx_co_liv.sql
new file mode 100644
index 00000000000..f76d4532439
--- /dev/null
+++ b/mysql/tables/llx_co_liv.sql
@@ -0,0 +1,30 @@
+-- ===================================================================
+-- Copyright (C) 2003 Rodolphe Quiedeville
+-- Copyright (C) 2008 Regis Houssin
+--
+-- This program is free software; you can redistribute it and/or modify
+-- it under the terms of the GNU General Public License as published by
+-- the Free Software Foundation; either version 2 of the License, or
+-- (at your option) any later version.
+--
+-- This program is distributed in the hope that it will be useful,
+-- but WITHOUT ANY WARRANTY; without even the implied warranty of
+-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+-- GNU General Public License for more details.
+--
+-- You should have received a copy of the GNU General Public License
+-- along with this program; if not, write to the Free Software
+-- Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+--
+-- $Id$
+-- ===================================================================
+
+create table llx_co_liv
+(
+ rowid integer AUTO_INCREMENT PRIMARY KEY,
+ fk_commande integer NOT NULL,
+ fk_livraison integer NOT NULL,
+
+ key(fk_commande),
+ key(fk_livraison)
+)type=innodb;
diff --git a/mysql/tables/llx_commande.sql b/mysql/tables/llx_commande.sql
index 04376528df6..397d7c533e9 100644
--- a/mysql/tables/llx_commande.sql
+++ b/mysql/tables/llx_commande.sql
@@ -50,7 +50,7 @@ create table llx_commande
facture tinyint default 0,
fk_cond_reglement integer, -- condition de réglement
fk_mode_reglement integer, -- mode de réglement
- date_livraison date default NULL,
+ date_livraison date default NULL,
fk_adresse_livraison integer, -- adresse de livraison
UNIQUE INDEX (ref)
diff --git a/mysql/tables/llx_expedition.key.sql b/mysql/tables/llx_expedition.key.sql
index cee509be72e..845a649b828 100644
--- a/mysql/tables/llx_expedition.key.sql
+++ b/mysql/tables/llx_expedition.key.sql
@@ -23,11 +23,13 @@
ALTER TABLE llx_expedition ADD INDEX idx_expedition_fk_soc (fk_soc);
ALTER TABLE llx_expedition ADD INDEX idx_expedition_fk_user_author (fk_user_author);
ALTER TABLE llx_expedition ADD INDEX idx_expedition_fk_user_valid (fk_user_valid);
+ALTER TABLE llx_expedition ADD INDEX idx_expedition_fk_adresse_livraison (fk_adresse_livraison);
ALTER TABLE llx_expedition ADD INDEX idx_expedition_fk_expedition_methode (fk_expedition_methode);
ALTER TABLE llx_expedition ADD CONSTRAINT fk_expedition_fk_soc FOREIGN KEY (fk_soc) REFERENCES llx_societe (rowid);
ALTER TABLE llx_expedition ADD CONSTRAINT fk_expedition_fk_user_author FOREIGN KEY (fk_user_author) REFERENCES llx_user (rowid);
ALTER TABLE llx_expedition ADD CONSTRAINT fk_expedition_fk_user_valid FOREIGN KEY (fk_user_valid) REFERENCES llx_user (rowid);
+ALTER TABLE llx_expedition ADD CONSTRAINT fk_expedition_fk_adresse_livraison FOREIGN KEY (fk_adresse_livraison) REFERENCES llx_societe_adresse_livraison (rowid);
ALTER TABLE llx_expedition ADD CONSTRAINT fk_expedition_fk_expedition_methode FOREIGN KEY (fk_expedition_methode) REFERENCES llx_expedition_methode (rowid);
ALTER TABLE llx_expedition ADD UNIQUE INDEX idx_expedition_uk_ref (ref);
\ No newline at end of file
diff --git a/mysql/tables/llx_expedition.sql b/mysql/tables/llx_expedition.sql
index fd92a82cc0d..34017567d56 100644
--- a/mysql/tables/llx_expedition.sql
+++ b/mysql/tables/llx_expedition.sql
@@ -25,12 +25,12 @@ create table llx_expedition
tms timestamp,
ref varchar(30) NOT NULL,
fk_soc integer NOT NULL,
- date_creation datetime, -- date de creation
- fk_user_author integer, -- createur
- date_valid datetime, -- date de validation
- fk_user_valid integer, -- valideur
- date_expedition date, -- date de l'expedition
- fk_adresse_livraison integer, -- adresse de livraison
+ date_creation datetime, -- date de creation
+ fk_user_author integer, -- createur
+ date_valid datetime, -- date de validation
+ fk_user_valid integer, -- valideur
+ date_expedition date, -- date de l'expedition
+ fk_adresse_livraison integer DEFAULT NULL, -- adresse de livraison
fk_expedition_methode integer,
fk_statut smallint DEFAULT 0,
note text,
diff --git a/mysql/tables/llx_livraison.key.sql b/mysql/tables/llx_livraison.key.sql
new file mode 100644
index 00000000000..911548843fc
--- /dev/null
+++ b/mysql/tables/llx_livraison.key.sql
@@ -0,0 +1,33 @@
+-- ===================================================================
+-- Copyright (C) 2005 Laurent Destailleur
+-- Copyright (C) 2008 Regis Houssin
+--
+-- This program is free software; you can redistribute it and/or modify
+-- it under the terms of the GNU General Public License as published by
+-- the Free Software Foundation; either version 2 of the License, or
+-- (at your option) any later version.
+--
+-- This program is distributed in the hope that it will be useful,
+-- but WITHOUT ANY WARRANTY; without even the implied warranty of
+-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+-- GNU General Public License for more details.
+--
+-- You should have received a copy of the GNU General Public License
+-- along with this program; if not, write to the Free Software
+-- Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+--
+-- $Id$
+-- ===================================================================
+
+
+ALTER TABLE llx_livraison ADD INDEX idx_livraison_fk_soc (fk_soc);
+ALTER TABLE llx_livraison ADD INDEX idx_livraison_fk_user_author (fk_user_author);
+ALTER TABLE llx_livraison ADD INDEX idx_livraison_fk_user_valid (fk_user_valid);
+ALTER TABLE llx_livraison ADD INDEX idx_livraison_fk_adresse_livraison (fk_adresse_livraison);
+
+ALTER TABLE llx_livraison ADD CONSTRAINT fk_livraison_fk_soc FOREIGN KEY (fk_soc) REFERENCES llx_societe (rowid);
+ALTER TABLE llx_livraison ADD CONSTRAINT fk_livraison_fk_user_author FOREIGN KEY (fk_user_author) REFERENCES llx_user (rowid);
+ALTER TABLE llx_livraison ADD CONSTRAINT fk_livraison_fk_user_valid FOREIGN KEY (fk_user_valid) REFERENCES llx_user (rowid);
+ALTER TABLE llx_livraison ADD CONSTRAINT fk_livraison_fk_adresse_livraison FOREIGN KEY (fk_adresse_livraison) REFERENCES llx_societe_adresse_livraison (rowid);
+
+ALTER TABLE llx_livraison ADD UNIQUE INDEX idx_livraison_uk_ref (ref);
\ No newline at end of file
diff --git a/mysql/tables/llx_livraison.sql b/mysql/tables/llx_livraison.sql
index 60a04cf43e2..7021893dea9 100644
--- a/mysql/tables/llx_livraison.sql
+++ b/mysql/tables/llx_livraison.sql
@@ -23,22 +23,19 @@ create table llx_livraison
(
rowid integer AUTO_INCREMENT PRIMARY KEY,
tms timestamp,
- fk_commande integer DEFAULT 0, -- commande auquel est rattache le bon de livraison
+ ref varchar(30) NOT NULL, -- delivery number
+ ref_client varchar(30), -- customer number
+ fk_soc integer NOT NULL,
fk_expedition integer, -- expedition auquel est rattache le bon de livraison
- ref varchar(30) NOT NULL, -- delivery number
date_creation datetime, -- date de creation
fk_user_author integer, -- createur du bon de livraison
date_valid datetime, -- date de validation
fk_user_valid integer, -- valideur du bon de livraison
- date_livraison date default NULL, -- date de livraison
+ date_livraison date default NULL, -- date de livraison
fk_adresse_livraison integer, -- adresse de livraison
- fk_statut smallint default 0,
- total_ht real default 0,
- total_ttc real default 0,
+ fk_statut smallint default 0,
+ total_ht double(24,8) default 0,
note text,
note_public text,
- model_pdf varchar(50),
-
- UNIQUE INDEX (ref),
- key(fk_commande)
+ model_pdf varchar(50)
)type=innodb;
diff --git a/mysql/tables/llx_livraisondet.key.sql b/mysql/tables/llx_livraisondet.key.sql
new file mode 100644
index 00000000000..92000240642
--- /dev/null
+++ b/mysql/tables/llx_livraisondet.key.sql
@@ -0,0 +1,24 @@
+-- ===================================================================
+-- Copyright (C) 2005 Laurent Destailleur
+-- Copyright (C) 2008 Regis Houssin
+--
+-- This program is free software; you can redistribute it and/or modify
+-- it under the terms of the GNU General Public License as published by
+-- the Free Software Foundation; either version 2 of the License, or
+-- (at your option) any later version.
+--
+-- This program is distributed in the hope that it will be useful,
+-- but WITHOUT ANY WARRANTY; without even the implied warranty of
+-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+-- GNU General Public License for more details.
+--
+-- You should have received a copy of the GNU General Public License
+-- along with this program; if not, write to the Free Software
+-- Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+--
+-- $Id$
+-- ===================================================================
+
+
+ALTER TABLE llx_livraisondet ADD INDEX idx_livraisondet_fk_expedition (fk_livraison);
+ALTER TABLE llx_livraisondet ADD CONSTRAINT fk_livraisondet_fk_livraison FOREIGN KEY (fk_livraison) REFERENCES llx_livraison (rowid);
diff --git a/mysql/tables/llx_livraisondet.sql b/mysql/tables/llx_livraisondet.sql
index 1e537d1e4c3..2ab519d58ea 100644
--- a/mysql/tables/llx_livraisondet.sql
+++ b/mysql/tables/llx_livraisondet.sql
@@ -22,9 +22,11 @@
create table llx_livraisondet
(
rowid integer AUTO_INCREMENT PRIMARY KEY,
- fk_livraison integer,
- fk_commande_ligne integer NOT NULL,
- qty real, -- quantité
- key(fk_livraison),
- key(fk_commande_ligne)
+ fk_livraison integer,
+ fk_product integer,
+ description text,
+ qty real, -- quantité
+ subprice double(24,8) DEFAULT 0, -- prix unitaire
+ total_ht double(24,8) DEFAULT 0, -- Total HT de la ligne toute quantité
+ rang integer DEFAULT 0
)type=innodb;