diff --git a/htdocs/product/stock/class/entrepot.class.php b/htdocs/product/stock/class/entrepot.class.php index fe36b6364fc..617550c09dd 100644 --- a/htdocs/product/stock/class/entrepot.class.php +++ b/htdocs/product/stock/class/entrepot.class.php @@ -445,7 +445,7 @@ class Entrepot extends CommonObject if ($id) { $sql .= " WHERE rowid = ".((int) $id); } else { - $sql .= " WHERE entity = ".$conf->entity; + $sql .= " WHERE entity IN (".getEntity('stock').")"; if ($ref) { $sql .= " AND ref = '".$this->db->escape($ref)."'"; } diff --git a/htdocs/product/stock/movement_list.php b/htdocs/product/stock/movement_list.php index 97d381e4f93..a1d143335cd 100644 --- a/htdocs/product/stock/movement_list.php +++ b/htdocs/product/stock/movement_list.php @@ -49,9 +49,6 @@ if (!empty($conf->productbatch->enabled)) { $langs->load("productbatch"); } -// Security check -$result = restrictedArea($user, 'stock'); - $id = GETPOST('id', 'int'); $ref = GETPOST('ref', 'alpha'); $msid = GETPOST('msid', 'int'); @@ -63,10 +60,6 @@ $cancel = GETPOST('cancel', 'alpha'); $contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'movementlist'; $toselect = GETPOST('toselect', 'array'); // Array of ids of elements selected into a list -// Security check -//$result=restrictedArea($user, 'stock', $id, 'entrepot&stock'); -$result = restrictedArea($user, 'stock'); - $idproduct = GETPOST('idproduct', 'int'); $sall = trim((GETPOST('search_all', 'alphanohtml') != '') ?GETPOST('search_all', 'alphanohtml') : GETPOST('sall', 'alphanohtml')); $search_date_startday = GETPOST('search_date_startday', 'int'); @@ -146,6 +139,18 @@ if (!empty($conf->global->PRODUCT_DISABLE_EATBY)) { unset($arrayfields['pl.eatby']); } + +$tmpwarehouse = new Entrepot($db); +if ($id > 0 || !empty($ref)) { + $tmpwarehouse->fetch($id, $ref); + $id = $tmpwarehouse->id; +} + + +// Security check +//$result=restrictedArea($user, 'stock', $id, 'entrepot&stock'); +$result = restrictedArea($user, 'stock'); + // Security check if (!$user->rights->stock->mouvement->lire) { accessforbidden(); @@ -216,9 +221,6 @@ if (empty($reshook)) { } if ($action == 'update_extras') { - $tmpwarehouse = new Entrepot($db); - $tmpwarehouse->fetch($id); - $tmpwarehouse->oldcopy = dol_clone($tmpwarehouse); // Fill array 'array_options' with data from update form