FIX : dont update object price on each iteration when updating situation for all lines

This commit is contained in:
Christophe Battarel 2022-04-07 15:59:42 +02:00
parent 637f73a833
commit 56bfa20d70
2 changed files with 11 additions and 5 deletions

View File

@ -2560,9 +2560,10 @@ if (empty($reshook)) {
setEventMessages($mesg, null, 'warnings');
$result = -1;
} else {
$object->update_percent($line, GETPOST('all_progress'));
$object->update_percent($line, GETPOST('all_progress'), false);
}
}
$object->update_price(1);
}
} elseif ($action == 'updateline' && $usercancreate && !$cancel) {
header('Location: '.$_SERVER["PHP_SELF"].'?facid='.$id); // To show again edited page

View File

@ -3725,11 +3725,12 @@ class Facture extends CommonInvoice
/**
* Update invoice line with percentage
*
* @param FactureLigne $line Invoice line
* @param int $percent Percentage
* @param FactureLigne $line Invoice line
* @param int $percent Percentage
* @param boolean $update_price Update object price
* @return void
*/
public function update_percent($line, $percent)
public function update_percent($line, $percent, $update_price = true)
{
// phpcs:enable
global $mysoc, $user;
@ -3756,7 +3757,11 @@ class Facture extends CommonInvoice
$line->multicurrency_total_tva = $tabprice[17];
$line->multicurrency_total_ttc = $tabprice[18];
$line->update($user);
$this->update_price(1);
// sometimes it is better to not update price for each line, ie when updating situation on all lines
if ($update_price) {
$this->update_price(1);
}
}
/**