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
This commit is contained in:
atm-corentin 2026-01-16 11:12:47 +01:00 committed by GitHub
parent 7f6966ee06
commit 9c04379799
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 15 additions and 8 deletions

View file

@ -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) {

View file

@ -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');