diff --git a/htdocs/comm/action/card.php b/htdocs/comm/action/card.php index f7ee9668206..7581ccd2c00 100644 --- a/htdocs/comm/action/card.php +++ b/htdocs/comm/action/card.php @@ -735,6 +735,7 @@ if (empty($reshook) && $action == 'update') { // type_id and type_code is not modified } else { $object->type_id = dol_getIdFromCode($db, GETPOST("actioncode", 'aZ09'), 'c_actioncomm'); + $object->type_code = GETPOST("actioncode", 'aZ09'); } $object->label = GETPOST("label", "alphanohtml"); diff --git a/htdocs/comm/action/class/actioncomm.class.php b/htdocs/comm/action/class/actioncomm.class.php index 98f5d455cd0..bc825ca3992 100644 --- a/htdocs/comm/action/class/actioncomm.class.php +++ b/htdocs/comm/action/class/actioncomm.class.php @@ -423,7 +423,7 @@ class ActionComm extends CommonObject */ public function create(User $user, $notrigger = 0) { - global $langs, $conf, $hookmanager; + global $langs, $conf; $error = 0; $now = dol_now(); @@ -707,10 +707,9 @@ class ActionComm extends CommonObject */ public function createFromClone(User $fuser, $socid) { - global $db, $conf, $hookmanager; + global $hookmanager; $error = 0; - $now = dol_now(); $this->db->begin(); @@ -1174,7 +1173,7 @@ class ActionComm extends CommonObject } $code = $this->code; - if (empty($code)) { + if (empty($code) || (!empty($this->oldcopy) && $this->oldcopy->type_code != $this->type_code)) { // If code unknown or if we change the type, we reset $code too $code = $this->type_code; } diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index dd961d289e2..7e78549e0fa 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -8959,7 +8959,11 @@ abstract class CommonObject // $this->{$field} may be null, '', 0, '0', 123, '123' if ((isset($this->{$field}) && $this->{$field} != '') || !empty($info['notnull'])) { if (!isset($this->{$field})) { - $queryarray[$field] = 0; + if (!empty($info['default'])) { + $queryarray[$field] = $info['default']; + } else { + $queryarray[$field] = 0; + } } else { $queryarray[$field] = (int) $this->{$field}; // If '0', it may be set to null later if $info['notnull'] == -1 } diff --git a/htdocs/fourn/facture/card.php b/htdocs/fourn/facture/card.php index 1738dd69868..240ac03f82f 100644 --- a/htdocs/fourn/facture/card.php +++ b/htdocs/fourn/facture/card.php @@ -3508,7 +3508,7 @@ if ($action == 'create') { } print ''; print ''; - print ''.(!empty($object->multicurrency_code) ? $object->multicurrency_code : $conf->currency).' '.price(price2num($object->multicurrency_tx*$resteapayeraffiche, 'MT')).' '; + print ''.(!empty($object->multicurrency_code) ? $object->multicurrency_code : $conf->currency).' '.price(price2num($multicurrency_resteapayer, 'MT')).' '; } } else { // Credit note $cssforamountpaymentcomplete = 'amountpaymentneutral';