diff --git a/class/actions_sendrecurringinvoicebymail.class.php b/class/actions_sendrecurringinvoicebymail.class.php index ccc9813..0209d6b 100644 --- a/class/actions_sendrecurringinvoicebymail.class.php +++ b/class/actions_sendrecurringinvoicebymail.class.php @@ -90,9 +90,9 @@ class Actionssendrecurringinvoicebymail return -1; } - // We only send the mail when the invoice is not a draft - // and the sending is enabled for the template. - if ($object->brouillon || !$mailObject->active) { + // Abort sending when inactive + // (draft invoice or explictly disabled) + if (!$mailObject->active) { return 0; } diff --git a/class/sribmcustommailinfo.class.php b/class/sribmcustommailinfo.class.php index 7f68e19..1a1a21e 100644 --- a/class/sribmcustommailinfo.class.php +++ b/class/sribmcustommailinfo.class.php @@ -368,6 +368,9 @@ class SRIBMCustomMailInfo extends CommonObject $this->subject = $template->topic; $this->body = $template->content; $this->addmaindocfile = $template->joinfiles; + // By default, we don't send emails when the generated invoice is + // still a draft. + $this->active = $this->fac_rec_object->auto_validate; } return 1;