Open jacotec opened 1 year ago
I can confirm that this is still happening in 18.0.2
This issue just bite me when it comes to stripe payments because the automatic notification sends this url:
/dolibarr/public/payment/newpayment.php?source=order&ref=%28PROV301%29&securekey=...
where as if I send the email manually then the url are:
/dolibarr/public/payment/newpayment.php?source=order&ref=SO2311-0065&securekey=...
I wish this bug would be prioritized higher, as it seems to affect more than just one place, this issue is most likely related https://github.com/Dolibarr/dolibarr/issues/26396
Notifications are generated before the triggering process is completed #25738
This is still an issue in 18.0.3 tuxgasy docker image
also related to #23682
The problem seems to be that the trigger, as it is currently designed, has a different purpose: By using it, a validation of an invoice can be prevented to happen. Therefore, the trigger is by design called, before the validation is completed.
What we need in many cases is a second trigger: one that confirms that a validation has been successfully completed in order to do something with the result (e.g. send validated invoice).
The problem seems to be that the trigger, as it is currently designed, has a different purpose: By using it, a validation of an invoice can be prevented to happen. Therefore, the trigger is by design called, before the validation is completed.
What we need in many cases is a second trigger: one that confirms that a validation has been successfully completed in order to do something with the result (e.g. send validated invoice).
thanks for explaining. It sounds like it would take a while before it would be solved.
Would it be possible to circumvent this by simply using a cronjob that would look for any "object" in the correct state and then send out the email? But what would prevent this cronjob from sending out the email again 5 minutes later?
As a quick fix you could create an extrafield as a flag, which gets checked and set, when the object is sent, to prevent double sending.
As a quick fix you could create an extrafield as a flag, which gets checked and set, when the object is sent, to prevent double sending.
True that could perhaps work. I would need 3 fields to as there are 3 I'd like to send email for, Proposal validated, Order Validated and Invoice Paid. Perhaps I could use bit vectors like 1, 2, 4, 8, ...
Then I either need to send email outside Dolibarr or wait for an API call to send emails :-/
What we need in many cases is a second trigger: one that confirms that a validation has been successfully completed in order to do something with the result (e.g. send validated invoice).
Is that the only possibility?
What if when the trigger happened a line was inserted into some database table stating that an (email) notification should be sent.
Then later, possibly using a cronjob the notification system could check that database table for such lines, actually send out notifications and then remove the line from the database table preventing it from being sent again.
Hello, First at all, sorry for my english! I have the same issue with automatic email notification on 20.0.1 version. The PDF order confirmation sent to customer is not the validated one. It is the draft one.
Bug
The "processing hook" of the module seems to be too early:
When an invoice is validated, the checkbox "append file" in the email template does nothing. The notification seems to be generated before the final invoice is completely generated.
The Reference still gives back the "PROV" number, not the final invoice number
When a notification is triggered by a completed payment, the attached document is still the original, old invoice - not the new version with the payment remark.
When a subscription triggers an automatic validated invoice, there is also no document attached. In this case, even the public download link placeholder is empty - so in this case no invoice at all can be sent to the customer automatically.
As a conclusion: The notification should be processed after all the things which had triggered the notification are completely processed. Or the notification should be in general delayed by a few seconds, so it can be assured that all the needed processes are completed before the notification is generated.
Environment Version
18.0.0
Environment OS
Ubuntu 22.04
Environment Web server
NGINX
Environment PHP
8.1
Environment Database
MariaDB 11
Environment URL(s)
No response
Expected and actual behavior
See above. The notification should be generated after all underlying processes which are triggering the notification are completed, so that it can be assured that all variables, links and attached files are already up-to-date.
Maybe a solution is to add a delay of a few seconds before the notification task is triggered, so that it can be assured that all underlying variables and documents are processed and up-to-date before generating the notification.
Steps to reproduce the behavior
Follow the procedure in the description and i.e. validate an invoice which sends a notification to the customer.
The reference is still the previois "PROV" number, the file is not attached (as the invoice is not yet finally generated when the notification is triggered).
Attached files
No response