diff --git a/htdocs/fourn/commande/fiche.php b/htdocs/fourn/commande/fiche.php
index 12aceae8347..3f0138ff226 100644
--- a/htdocs/fourn/commande/fiche.php
+++ b/htdocs/fourn/commande/fiche.php
@@ -626,13 +626,11 @@ else
*/
print '
';
- $sql = "SELECT l.ref as ref_fourn, l.fk_prod_fourn_price, l.description, l.price, l.qty";
+ $sql = "SELECT l.ref as ref_fourn, l.fk_product, l.description, l.price, l.qty";
$sql.= ", l.rowid, l.tva_tx, l.remise_percent, l.subprice";
$sql.= ", p.rowid as product_id, p.label, p.ref";
$sql.= " FROM ".MAIN_DB_PREFIX."commande_fournisseurdet as l";
- $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'product_fournisseur_price as pfp ON l.fk_prod_fourn_price = pfp.rowid';
- $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'product_fournisseur as pf ON pfp.fk_product_fournisseur = pf.rowid';
- $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'product as p ON pf.fk_product = p.rowid';
+ $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'product as p ON l.fk_product = p.rowid';
$sql.= " WHERE l.fk_commande = ".$commande->id;
$sql.= " ORDER BY l.rowid";
diff --git a/htdocs/fourn/fournisseur.commande.class.php b/htdocs/fourn/fournisseur.commande.class.php
index 99e5efeaa45..caf1ee7e919 100644
--- a/htdocs/fourn/fournisseur.commande.class.php
+++ b/htdocs/fourn/fournisseur.commande.class.php
@@ -112,12 +112,10 @@ class CommandeFournisseur extends Commande
// export pdf -----------
$this->lignes = array();
- $sql = 'SELECT l.fk_prod_fourn_price, l.description, l.price, l.qty, l.rowid, l.tva_tx, l.remise_percent, l.subprice,';
+ $sql = 'SELECT l.fk_product, l.description, l.price, l.qty, l.rowid, l.tva_tx, l.remise_percent, l.subprice,';
$sql.= ' p.label, p.description as product_desc, p.ref, p.rowid as prodid';
$sql.= ' FROM '.MAIN_DB_PREFIX.'commande_fournisseurdet as l';
- $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'product_fournisseur_price as pfp ON l.fk_prod_fourn_price = pfp.rowid';
- $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'product_fournisseur as pf ON pfp.fk_product_fournisseur = pf.rowid';
- $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'product as p ON pf.fk_product = p.rowid';
+ $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'product as p ON l.fk_product = p.rowid';
$sql.= ' WHERE l.fk_commande = '.$this->id;
$sql.= ' ORDER BY l.rowid';
$result = $this->db->query($sql);
@@ -138,7 +136,6 @@ class CommandeFournisseur extends Commande
$ligne->subprice = $objp->subprice;
$ligne->remise_percent = $objp->remise_percent;
$ligne->price = $objp->price;
- $ligne->fk_prod_fourn_price = $objp->fk_prod_fourn_price;
$ligne->libelle = $objp->label; // Label produit
$ligne->product_desc = $objp->product_desc; // Description produit
@@ -719,8 +716,8 @@ class CommandeFournisseur extends Commande
$price = $pu - $remise;
}
- $sql = "INSERT INTO ".MAIN_DB_PREFIX."commande_fournisseurdet (fk_commande,label,description,fk_prod_fourn_price, price, qty, tva_tx, remise_percent, subprice, remise, ref)";
- $sql .= " VALUES (".$this->id.", '" . addslashes($label) . "','" . addslashes($desc) . "',".$fk_prod_fourn_price.",".price2num($price,'MU').", '$qty', $txtva, $remise_percent,'".price2num($subprice,'MU')."','".price2num($remise)."','".$ref."') ;";
+ $sql = "INSERT INTO ".MAIN_DB_PREFIX."commande_fournisseurdet (fk_commande,label,description,fk_product, price, qty, tva_tx, remise_percent, subprice, remise, ref)";
+ $sql .= " VALUES (".$this->id.", '" . addslashes($label) . "','" . addslashes($desc) . "',".$fk_product.",".price2num($price,'MU').", '$qty', $txtva, $remise_percent,'".price2num($subprice,'MU')."','".price2num($remise)."','".$ref."') ;";
dolibarr_syslog('Fournisseur.commande.class::addline sql='.$sql);
$resql=$this->db->query($sql);
if ($resql)
diff --git a/mysql/migration/2.1.0-2.2.0.sql b/mysql/migration/2.1.0-2.2.0.sql
index 49539e3c2bf..b23906d1191 100644
--- a/mysql/migration/2.1.0-2.2.0.sql
+++ b/mysql/migration/2.1.0-2.2.0.sql
@@ -870,5 +870,4 @@ ALTER TABLE llx_product_fournisseur_price ADD INDEX idx_product_fournisseur_pric
ALTER TABLE llx_product_fournisseur_price_log DROP COLUMN fk_soc;
ALTER TABLE llx_product_fournisseur_price_log CHANGE fk_product fk_product_fournisseur integer NOT NULL;
-ALTER TABLE llx_commande_fournisseurdet MODIFY fk_commande integer NOT NULL;
-ALTER TABLE llx_commande_fournisseurdet CHANGE fk_product fk_prod_fourn_price integer NOT NULL;
\ No newline at end of file
+ALTER TABLE llx_commande_fournisseurdet MODIFY fk_commande integer NOT NULL;
\ No newline at end of file
diff --git a/mysql/tables/llx_commande_fournisseurdet.sql b/mysql/tables/llx_commande_fournisseurdet.sql
index 7ce2aef78ef..8ba96da9434 100644
--- a/mysql/tables/llx_commande_fournisseurdet.sql
+++ b/mysql/tables/llx_commande_fournisseurdet.sql
@@ -24,7 +24,7 @@ create table llx_commande_fournisseurdet
(
rowid integer AUTO_INCREMENT PRIMARY KEY,
fk_commande integer NOT NULL,
- fk_prod_fourn_price integer NOT NULL,
+ fk_product integer NOT NULL,
ref varchar(50),
label varchar(255),
description text,