Merge pull request #21448 from atm-jpb/patch-1

# FIX : rank duplicate on mass action
This commit is contained in:
Laurent Destailleur 2022-07-07 20:57:51 +02:00 committed by GitHub
commit 63ce535deb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -643,6 +643,8 @@ if ($massaction == 'confirm_createbills') { // Create bills from orders.
$db->begin(); $db->begin();
$nbOrders = is_array($orders) ? count($orders) : 1;
foreach ($orders as $id_order) { foreach ($orders as $id_order) {
$cmd = new Commande($db); $cmd = new Commande($db);
if ($cmd->fetch($id_order) <= 0) { if ($cmd->fetch($id_order) <= 0) {
@ -774,7 +776,7 @@ if ($massaction == 'confirm_createbills') { // Create bills from orders.
} }
$objecttmp->context['createfromclone']; $objecttmp->context['createfromclone'];
$rankedLine = ($nbOrders > 1) ? -1 : $lines[$i]->rang;
$result = $objecttmp->addline( $result = $objecttmp->addline(
$desc, $desc,
$lines[$i]->subprice, $lines[$i]->subprice,
@ -792,7 +794,9 @@ if ($massaction == 'confirm_createbills') { // Create bills from orders.
'HT', 'HT',
0, 0,
$product_type, $product_type,
$lines[$i]->rang, //we have define the max rank for each line which makes it possible not to have a duplicate on the rank field in the case of several orders
//-1 will give us the right number
$rankedLine, // rank
$lines[$i]->special_code, $lines[$i]->special_code,
$objecttmp->origin, $objecttmp->origin,
$lines[$i]->rowid, $lines[$i]->rowid,