Check if the lines in create is type object (like supplier invoice)

This commit is contained in:
Cserveny, Tamás 2022-01-20 00:55:52 +01:00
parent 22a3b5ea78
commit 115f022ae9

View File

@ -1357,32 +1357,38 @@ class CommandeFournisseur extends CommonOrder
if ($this->id) { if ($this->id) {
$num = count($this->lines); $num = count($this->lines);
// insert products details into database // insert products details into database
for ($i = 0; $i < $num; $i++) { for ($i = 0; $i < $num; $i++) {
$this->special_code = $this->lines[$i]->special_code; // TODO : remove this in 9.0 and add special_code param to addline() $line = $this->lines[$i];
if (!is_object($line)) {
$line = (object) $line;
}
$this->special_code = $line->special_code; // TODO : remove this in 9.0 and add special_code param to addline()
// This include test on qty if option SUPPLIER_ORDER_WITH_NOPRICEDEFINED is not set // This include test on qty if option SUPPLIER_ORDER_WITH_NOPRICEDEFINED is not set
$result = $this->addline( $result = $this->addline(
$this->lines[$i]->desc, $line->desc,
$this->lines[$i]->subprice, $line->subprice,
$this->lines[$i]->qty, $line->qty,
$this->lines[$i]->tva_tx, $line->tva_tx,
$this->lines[$i]->localtax1_tx, $line->localtax1_tx,
$this->lines[$i]->localtax2_tx, $line->localtax2_tx,
$this->lines[$i]->fk_product, $line->fk_product,
0, 0,
$this->lines[$i]->ref_fourn, // $this->lines[$i]->ref_fourn comes from field ref into table of lines. Value may ba a ref that does not exists anymore, so we first try with value of product $line->ref_fourn, // $line->ref_fourn comes from field ref into table of lines. Value may ba a ref that does not exists anymore, so we first try with value of product
$this->lines[$i]->remise_percent, $line->remise_percent,
'HT', 'HT',
0, 0,
$this->lines[$i]->product_type, $line->product_type,
$this->lines[$i]->info_bits, $line->info_bits,
false, false,
$this->lines[$i]->date_start, $line->date_start,
$this->lines[$i]->date_end, $line->date_end,
$this->lines[$i]->array_options, $line->array_options,
$this->lines[$i]->fk_unit $line->fk_unit
); );
if ($result < 0) { 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 functionnal error dol_syslog(get_class($this)."::create ".$this->error, LOG_WARNING); // do not use dol_print_error here as it may be a functionnal error