diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index 7abd140b9b9..ee1d904dc41 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -2821,7 +2821,8 @@ class Facture extends CommonInvoice */ function deleteline($rowid) { - + global $user; + dol_syslog(get_class($this)."::deleteline rowid=".$rowid, LOG_DEBUG); if (! $this->brouillon) @@ -2847,13 +2848,14 @@ class Facture extends CommonInvoice } $line=new FactureLigne($this->db); - + $line->context = $this->context; // For triggers - $line->fetch($rowid); - - if ($line->delete() > 0) + $result = $line->fetch($rowid); + if (! ($result > 0)) dol_print_error($db, $line->error, $line->errors); + + if ($line->delete($user) > 0) { $result=$this->update_price(1); @@ -4208,13 +4210,13 @@ class FactureLigne extends CommonInvoiceLine $sql.= ' fd.date_start as date_start, fd.date_end as date_end, fd.fk_product_fournisseur_price as fk_fournprice, fd.buy_price_ht as pa_ht,'; $sql.= ' fd.info_bits, fd.special_code, fd.total_ht, fd.total_tva, fd.total_ttc, fd.total_localtax1, fd.total_localtax2, fd.rang,'; $sql.= ' fd.fk_code_ventilation,'; - $sql.= ' fd.fk_unit, fk_user_author, fk_user_modif,'; + $sql.= ' fd.fk_unit, fd.fk_user_author, fd.fk_user_modif,'; $sql.= ' fd.situation_percent, fd.fk_prev_id,'; + $sql.= ' fd.multicurrency_subprice,'; + $sql.= ' fd.multicurrency_total_ht,'; + $sql.= ' fd.multicurrency_total_tva,'; + $sql.= ' fd.multicurrency_total_ttc,'; $sql.= ' p.ref as product_ref, p.label as product_libelle, p.description as product_desc'; - $sql.= ' , fd.multicurrency_subprice'; - $sql.= ' , fd.multicurrency_total_ht'; - $sql.= ' , fd.multicurrency_total_tva'; - $sql.= ' , fd.multicurrency_total_ttc'; $sql.= ' FROM '.MAIN_DB_PREFIX.'facturedet as fd'; $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'product as p ON fd.fk_product = p.rowid'; $sql.= ' WHERE fd.rowid = '.$rowid; @@ -4278,6 +4280,7 @@ class FactureLigne extends CommonInvoiceLine } else { + $this->error = $this->db->lasterror(); return -1; } } @@ -4633,8 +4636,9 @@ class FactureLigne extends CommonInvoiceLine /** * Delete line in database - * - * @return int <0 if KO, >0 if OK + * TODO Add param User $user and notrigger (see skeleton) + * + * @return int <0 if KO, >0 if OK */ function delete() {