diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index a9244ac6b2f..0ba12140984 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -2707,6 +2707,8 @@ class Facture extends CommonInvoice { $error = 0; + $this->oldcopy = dol_clone($this, 2); // @phan-suppress-current-line PhanTypeMismatchProperty + // Clean parameters if (empty($this->type)) { $this->type = self::TYPE_STANDARD; diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index f6d4dec026b..b015331d215 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -2713,16 +2713,25 @@ abstract class CommonObject dol_syslog(get_class($this).'::setPaymentMethods('.$id.')'); if ($this->status >= 0 || $this->element == 'societe') { + $this->oldcopy = dol_clone($this, 2); // @phan-suppress-current-line PhanTypeMismatchProperty + // TODO uniformize field name $fieldname = 'fk_mode_reglement'; + $triggerName = (empty($this->TRIGGER_PREFIX) ? strtoupper(get_class($this)) : $this->TRIGGER_PREFIX); if ($this->element == 'societe') { $fieldname = 'mode_reglement'; + $triggerName = 'COMPANY'; + } + if (get_class($this) == 'Facture') { + $triggerName = 'BILL'; } if (get_class($this) == 'Fournisseur') { $fieldname = 'mode_reglement_supplier'; + $triggerName = 'BILL_SUPPLIER'; } if (get_class($this) == 'Tva') { $fieldname = 'fk_typepayment'; + $triggerName = 'VAT'; } if (get_class($this) == 'Salary') { $fieldname = 'fk_typepayment'; @@ -2738,10 +2747,10 @@ abstract class CommonObject if (get_class($this) == 'Fournisseur') { $this->mode_reglement_supplier_id = $id; } + // Triggers if (!$error && !$notrigger) { // Call triggers - $triggerName = (empty($this->TRIGGER_PREFIX) ? strtoupper(get_class($this)) : $this->TRIGGER_PREFIX); $result = $this->call_trigger($triggerName.'_MODIFY', $user); if ($result < 0) { $error++;