From 9c04379799b062eb0d8efbabbf71bcc9e1a646e5 Mon Sep 17 00:00:00 2001 From: atm-corentin <165782689+atm-corentin@users.noreply.github.com> Date: Fri, 16 Jan 2026 11:12:47 +0100 Subject: [PATCH] NEW : add support for label field in addline method In supplier order (#36544) * add support for label field in addline method to set description when empty * update --- htdocs/fourn/class/fournisseur.commande.class.php | 12 +++++++++--- htdocs/fourn/commande/card.php | 11 ++++++----- 2 files changed, 15 insertions(+), 8 deletions(-) diff --git a/htdocs/fourn/class/fournisseur.commande.class.php b/htdocs/fourn/class/fournisseur.commande.class.php index 80d173f0941..c903080fa74 100644 --- a/htdocs/fourn/class/fournisseur.commande.class.php +++ b/htdocs/fourn/class/fournisseur.commande.class.php @@ -1718,8 +1718,9 @@ class CommandeFournisseur extends CommonOrder $line->origin, // origin $line->origin_id, // origin_id $line->rang, // rang - $line->special_code - ); + $line->special_code, + isset($line->label) ? $line->label : '' + ); if ($result < 0) { dol_syslog(get_class($this)."::create ".$this->error, LOG_WARNING); // do not use dol_print_error here as it may be a functional error $this->db->rollback(); @@ -2022,9 +2023,10 @@ class CommandeFournisseur extends CommonOrder * @param int $origin_id Id of origin object * @param int $rang Rank * @param int $special_code Special code + * @param string $label Line label (used when desc is empty) * @return int Return integer <=0 if KO, >0 if OK */ - public function addline($desc, $pu_ht, $qty, $txtva, $txlocaltax1 = 0.0, $txlocaltax2 = 0.0, $fk_product = 0, $fk_prod_fourn_price = 0, $ref_supplier = '', $remise_percent = 0.0, $price_base_type = 'HT', $pu_ttc = 0.0, $type = 0, $info_bits = 0, $notrigger = 0, $date_start = null, $date_end = null, $array_options = [], $fk_unit = null, $pu_ht_devise = 0, $origin = '', $origin_id = 0, $rang = -1, $special_code = 0) + public function addline($desc, $pu_ht, $qty, $txtva, $txlocaltax1 = 0.0, $txlocaltax2 = 0.0, $fk_product = 0, $fk_prod_fourn_price = 0, $ref_supplier = '', $remise_percent = 0.0, $price_base_type = 'HT', $pu_ttc = 0.0, $type = 0, $info_bits = 0, $notrigger = 0, $date_start = null, $date_end = null, $array_options = [], $fk_unit = null, $pu_ht_devise = 0, $origin = '', $origin_id = 0, $rang = -1, $special_code = 0, $label = '') { global $langs, $mysoc; @@ -2072,7 +2074,11 @@ class CommandeFournisseur extends CommonOrder } else { $pu = $pu_ttc; } + $label = trim((string) $label); $desc = trim($desc); + if ($desc === '' && $label !== '') { + $desc = $label; + } // Check parameters if ($qty < 0 && !$fk_product) { diff --git a/htdocs/fourn/commande/card.php b/htdocs/fourn/commande/card.php index c79b3447c9c..6f6df50d43a 100644 --- a/htdocs/fourn/commande/card.php +++ b/htdocs/fourn/commande/card.php @@ -1693,11 +1693,12 @@ if (empty($reshook)) { $array_option, $lines[$i]->fk_unit, 0, - $element, - !empty($lines[$i]->id) ? $lines[$i]->id : $lines[$i]->rowid, - -1, - $lines[$i]->special_code - ); + $element, + !empty($lines[$i]->id) ? $lines[$i]->id : $lines[$i]->rowid, + -1, + $lines[$i]->special_code, + $label + ); if ($result < 0) { setEventMessages($object->error, $object->errors, 'errors');