Merge pull request #9199 from atm-quentin/FIX_hook_update_price

NEW Add hook changeRoundingMode in update_price
This commit is contained in:
Laurent Destailleur 2018-08-12 18:17:52 +02:00 committed by GitHub
commit 2f559a7edb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 7 additions and 2 deletions

View File

@ -3854,6 +3854,7 @@ class OrderLine extends CommonOrderLine
{
$objp = $this->db->fetch_object($result);
$this->rowid = $objp->rowid;
$this->id = $objp->rowid;
$this->fk_commande = $objp->fk_commande;
$this->fk_parent_line = $objp->fk_parent_line;
$this->label = $objp->custom_label;

View File

@ -4331,6 +4331,7 @@ class FactureLigne extends CommonInvoiceLine
$objp = $this->db->fetch_object($result);
$this->rowid = $objp->rowid;
$this->id = $objp->rowid;
$this->fk_facture = $objp->fk_facture;
$this->fk_parent_line = $objp->fk_parent_line;
$this->label = $objp->custom_label;

View File

@ -2573,7 +2573,7 @@ abstract class CommonObject
*/
function update_price($exclspec=0,$roundingadjust='none',$nodatabaseupdate=0,$seller=null)
{
global $conf;
global $conf, $hookmanager, $action;
// Some external module want no update price after a trigger because they have another method to calculate the total (ex: with an extrafield)
$MODULE = "";
@ -2664,7 +2664,10 @@ abstract class CommonObject
$obj = $this->db->fetch_object($resql);
// Note: There is no check on detail line and no check on total, if $forcedroundingmode = 'none'
if ($forcedroundingmode == '0') // Check if data on line are consistent. This may solve lines that were not consistent because set with $forcedroundingmode='auto'
$parameters=array('fk_element' => $obj->rowid);
$reshook = $hookmanager->executeHooks('changeRoundingMode', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
if (empty($reshook) && $forcedroundingmode == '0') // Check if data on line are consistent. This may solve lines that were not consistent because set with $forcedroundingmode='auto'
{
$localtax_array=array($obj->localtax1_type,$obj->localtax1_tx,$obj->localtax2_type,$obj->localtax2_tx);
$tmpcal=calcul_price_total($obj->qty, $obj->up, $obj->remise_percent, $obj->vatrate, $obj->localtax1_tx, $obj->localtax2_tx, 0, 'HT', $obj->info_bits, $obj->product_type, $seller, $localtax_array, (isset($obj->situation_percent) ? $obj->situation_percent : 100), $multicurrency_tx);