diff --git a/htdocs/compta/facture/class/facture-rec.class.php b/htdocs/compta/facture/class/facture-rec.class.php index ebd1313d82f..aab0841fc0b 100644 --- a/htdocs/compta/facture/class/facture-rec.class.php +++ b/htdocs/compta/facture/class/facture-rec.class.php @@ -2068,6 +2068,10 @@ class FactureRec extends CommonInvoice } if (!$notrigger) { + if (empty($this->context['actionmsgmore'])) { + $this->context['actionmsgmore'] = 'Trigger called by setNextDate'; + } + // Call trigger $result = $this->call_trigger('BILLREC_MODIFY', $user); if ($result < 0) { diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index 4b6872cb32c..080b6cbc8f4 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -637,8 +637,10 @@ class Facture extends CommonInvoice $_facrec->date_when = $now; } $next_date = $_facrec->getNextDate(); // Calculate next date + $result = $_facrec->setValueFrom('date_last_gen', $now, '', null, 'date', '', $user, ''); //$_facrec->setValueFrom('nb_gen_done', $_facrec->nb_gen_done + 1); // Not required, +1 already included into setNextDate when second param is 1. + $result = $_facrec->setNextDate($next_date, 1); } @@ -808,8 +810,8 @@ class Facture extends CommonInvoice } // Propagate contacts - if (!$error && $this->id && getDolGlobalString('MAIN_PROPAGATE_CONTACTS_FROM_ORIGIN') && !empty($this->origin) && !empty($this->origin_id)) { // Get contact from origin object - $originforcontact = $this->origin; + if (!$error && $this->id && getDolGlobalString('MAIN_PROPAGATE_CONTACTS_FROM_ORIGIN') && (!empty($this->origin_type) || !empty($this->origin)) && !empty($this->origin_id)) { // Get contact from origin object + $originforcontact = empty($this->origin_type) ? $this->origin : $this->origin_type; $originidforcontact = $this->origin_id; if ($originforcontact == 'shipping') { // shipment and order share the same contacts. If creating from shipment we take data of order require_once DOL_DOCUMENT_ROOT.'/expedition/class/expedition.class.php'; diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index bcc5376b9cb..a6933803b2b 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -2359,6 +2359,10 @@ abstract class CommonObject $this->oldcopy->$field = $oldvalue; } + if (empty($this->context['actionmsgmore'])) { + $this->context['actionmsgmore'] = 'Trigger called by setValueFrom'; + } + if ($result >= 0) { $result = $this->call_trigger($trigkey, (!empty($fuser) && is_object($fuser)) ? $fuser : $user); // This may set this->errors }