diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php
index cb8bc2ee872..2f1cf0b45fc 100644
--- a/htdocs/core/class/html.form.class.php
+++ b/htdocs/core/class/html.form.class.php
@@ -1394,6 +1394,7 @@ class Form
$sql = "SELECT price, price_ttc, price_base_type, tva_tx";
$sql.= " FROM ".MAIN_DB_PREFIX."product_price";
$sql.= " WHERE fk_product='".$objp->rowid."'";
+ $sql.= " AND entity IN (".getEntity('productprice', 1).")";
$sql.= " AND price_level=".$price_level;
$sql.= " ORDER BY date_price";
$sql.= " DESC LIMIT 1";
diff --git a/htdocs/product/ajax/products.php b/htdocs/product/ajax/products.php
index 3fed5d5152c..d27684b90aa 100644
--- a/htdocs/product/ajax/products.php
+++ b/htdocs/product/ajax/products.php
@@ -1,6 +1,6 @@
- * Copyright (C) 2005-2012 Regis Houssin
+ * Copyright (C) 2005-2013 Regis Houssin
* Copyright (C) 2007-2011 Laurent Destailleur
*
* This program is free software; you can redistribute it and/or modify
@@ -70,7 +70,7 @@ if (! empty($action) && $action == 'fetch' && ! empty($id))
$outdiscount=0;
$found=false;
-
+
// Price by qty
if (!empty($price_by_qty_rowid) && $price_by_qty_rowid >= 1) // If we need a particular price related to qty
{
@@ -101,6 +101,7 @@ if (! empty($action) && $action == 'fetch' && ! empty($id))
$sql = "SELECT price, price_ttc, price_base_type, tva_tx";
$sql.= " FROM ".MAIN_DB_PREFIX."product_price ";
$sql.= " WHERE fk_product='".$id."'";
+ $sql.= " AND entity IN (".getEntity('productprice', 1).")";
$sql.= " AND price_level=".$price_level;
$sql.= " ORDER BY date_price";
$sql.= " DESC LIMIT 1";
@@ -169,4 +170,4 @@ else
if ($outjson) print json_encode($arrayresult);
}
-?>
\ No newline at end of file
+?>
diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php
index 6888c144a7c..ea5121e7416 100644
--- a/htdocs/product/class/product.class.php
+++ b/htdocs/product/class/product.class.php
@@ -1,7 +1,7 @@
* Copyright (C) 2004-2011 Laurent Destailleur
- * Copyright (C) 2005-2012 Regis Houssin
+ * Copyright (C) 2005-2013 Regis Houssin
* Copyright (C) 2006 Andre Cianfarani
* Copyright (C) 2007-2011 Jean Heimburger
* Copyright (C) 2010-2011 Juanjo Menent
@@ -831,13 +831,15 @@ class Product extends CommonObject
*/
function _log_price($user,$level=0)
{
+ global $conf;
+
$now=dol_now();
// Add new price
$sql = "INSERT INTO ".MAIN_DB_PREFIX."product_price(price_level,date_price,fk_product,fk_user_author,price,price_ttc,price_base_type,tosell,tva_tx,recuperableonly,";
- $sql.= " localtax1_tx, localtax2_tx, price_min,price_min_ttc,price_by_qty) ";
+ $sql.= " localtax1_tx, localtax2_tx, price_min,price_min_ttc,price_by_qty,entity) ";
$sql.= " VALUES(".($level?$level:1).", '".$this->db->idate($now)."',".$this->id.",".$user->id.",".$this->price.",".$this->price_ttc.",'".$this->price_base_type."',".$this->status.",".$this->tva_tx.",".$this->tva_npr.",";
- $sql.= " ".$this->localtax1_tx.",".$this->localtax2_tx.",".$this->price_min.",".$this->price_min_ttc.",".$this->price_by_qty;
+ $sql.= " ".$this->localtax1_tx.",".$this->localtax2_tx.",".$this->price_min.",".$this->price_min_ttc.",".$this->price_by_qty.",".$conf->entity;
$sql.= ")";
dol_syslog(get_class($this)."_log_price sql=".$sql);
@@ -1205,7 +1207,8 @@ class Product extends CommonObject
$sql = "SELECT price, price_ttc, price_min, price_min_ttc,";
$sql.= " price_base_type, tva_tx, tosell, price_by_qty, rowid";
$sql.= " FROM ".MAIN_DB_PREFIX."product_price";
- $sql.= " WHERE price_level=".$i;
+ $sql.= " WHERE entity IN (".getEntity('productprice', 1).")";
+ $sql.= " AND price_level=".$i;
$sql.= " AND fk_product = '".$this->id."'";
$sql.= " ORDER BY date_price DESC";
$sql.= " LIMIT 1";
diff --git a/htdocs/product/price.php b/htdocs/product/price.php
index 2d0a1816982..4b27e2f6960 100644
--- a/htdocs/product/price.php
+++ b/htdocs/product/price.php
@@ -2,7 +2,7 @@
/* Copyright (C) 2001-2007 Rodolphe Quiedeville
* Copyright (C) 2004-2012 Laurent Destailleur
* Copyright (C) 2005 Eric Seigne
- * Copyright (C) 2005-2012 Regis Houssin
+ * Copyright (C) 2005-2013 Regis Houssin
* Copyright (C) 2006 Andre Cianfarani
*
* This program is free software; you can redistribute it and/or modify
@@ -664,6 +664,7 @@ $sql.= " p.date_price as dp, u.rowid as user_id, u.login";
$sql.= " FROM ".MAIN_DB_PREFIX."product_price as p,";
$sql.= " ".MAIN_DB_PREFIX."user as u";
$sql.= " WHERE fk_product = ".$object->id;
+$sql.= " AND p.entity IN (".getEntity('productprice', 1).")";
$sql.= " AND p.fk_user_author = u.rowid";
if (! empty($socid) && ! empty($conf->global->PRODUIT_MULTIPRICES)) $sql.= " AND p.price_level = ".$soc->price_level;
$sql.= " ORDER BY p.date_price DESC, p.price_level ASC";