diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 57af87a8d13..5a9ce90af0d 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -9899,14 +9899,16 @@ abstract class CommonObject } // Force values to default values when known - foreach ($this->fields as $key => $value) { - // If fields are already set, do nothing - if (array_key_exists($key, $fields)) { - continue; - } + if (property_exists($this, 'fields')) { + foreach ($this->fields as $key => $value) { + // If fields are already set, do nothing + if (array_key_exists($key, $fields)) { + continue; + } - if (!empty($value['default'])) { - $this->$key = $value['default']; + if (!empty($value['default'])) { + $this->$key = $value['default']; + } } } diff --git a/htdocs/expedition/card.php b/htdocs/expedition/card.php index c668cdef2be..7dcca9eace9 100644 --- a/htdocs/expedition/card.php +++ b/htdocs/expedition/card.php @@ -375,7 +375,7 @@ if (empty($reshook)) { $entrepot_id = 0; } - $ret = $object->addline($entrepot_id, GETPOST($idl, 'int'), GETPOST($qty, 'int'), $array_options[$i]); + $ret = $object->addline($entrepot_id, GETPOST($idl, 'int'), GETPOSTINT($qty), $array_options[$i]); if ($ret < 0) { setEventMessages($object->error, $object->errors, 'errors'); $error++;