FIX wrong list of stock mvt after right/left on a warehouse

This commit is contained in:
Laurent Destailleur 2021-12-12 00:17:14 +01:00
parent 3abb3f5018
commit b1038e0d48
2 changed files with 13 additions and 11 deletions

View File

@ -445,7 +445,7 @@ class Entrepot extends CommonObject
if ($id) { if ($id) {
$sql .= " WHERE rowid = ".((int) $id); $sql .= " WHERE rowid = ".((int) $id);
} else { } else {
$sql .= " WHERE entity = ".$conf->entity; $sql .= " WHERE entity IN (".getEntity('stock').")";
if ($ref) { if ($ref) {
$sql .= " AND ref = '".$this->db->escape($ref)."'"; $sql .= " AND ref = '".$this->db->escape($ref)."'";
} }

View File

@ -49,9 +49,6 @@ if (!empty($conf->productbatch->enabled)) {
$langs->load("productbatch"); $langs->load("productbatch");
} }
// Security check
$result = restrictedArea($user, 'stock');
$id = GETPOST('id', 'int'); $id = GETPOST('id', 'int');
$ref = GETPOST('ref', 'alpha'); $ref = GETPOST('ref', 'alpha');
$msid = GETPOST('msid', 'int'); $msid = GETPOST('msid', 'int');
@ -63,10 +60,6 @@ $cancel = GETPOST('cancel', 'alpha');
$contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'movementlist'; $contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'movementlist';
$toselect = GETPOST('toselect', 'array'); // Array of ids of elements selected into a list $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'); $idproduct = GETPOST('idproduct', 'int');
$sall = trim((GETPOST('search_all', 'alphanohtml') != '') ?GETPOST('search_all', 'alphanohtml') : GETPOST('sall', 'alphanohtml')); $sall = trim((GETPOST('search_all', 'alphanohtml') != '') ?GETPOST('search_all', 'alphanohtml') : GETPOST('sall', 'alphanohtml'));
$search_date_startday = GETPOST('search_date_startday', 'int'); $search_date_startday = GETPOST('search_date_startday', 'int');
@ -146,6 +139,18 @@ if (!empty($conf->global->PRODUCT_DISABLE_EATBY)) {
unset($arrayfields['pl.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 // Security check
if (!$user->rights->stock->mouvement->lire) { if (!$user->rights->stock->mouvement->lire) {
accessforbidden(); accessforbidden();
@ -216,9 +221,6 @@ if (empty($reshook)) {
} }
if ($action == 'update_extras') { if ($action == 'update_extras') {
$tmpwarehouse = new Entrepot($db);
$tmpwarehouse->fetch($id);
$tmpwarehouse->oldcopy = dol_clone($tmpwarehouse); $tmpwarehouse->oldcopy = dol_clone($tmpwarehouse);
// Fill array 'array_options' with data from update form // Fill array 'array_options' with data from update form