thank you for sharing the “best practice”. i tried / migrated “the code” to my case.
it works very well by get “id” (generateUniqueId) through “ID Server” and show “id” in document.
one more question is, if ARReport include 2-or-more analysisrequests, then each analysisrequest save the report individually (i have actived). the “id” of ARReport object stored in system is consumed and increment 2-or-more. but get “id” through “ID Server” only increment 1.
then when publish the next report, i will got the “id” show in document and the “id” of ARReport object stored in system are not the same.
so is there a way to adapt “id” when create ARReport object? (for example, the first analysisrequest using xxxx-01, second xxxx-02)
There's another option: generating a UID for each render. Something like this:
<span tal:content="python: str(view.generateId())[:20]"></span>
def generateId(self):
import uuid
return uuid.uuid4()
This would generate a unique ID for each render. Although it wouldn't match the ServerID, it guarantees that the ID is unique in the PDF.
The problem with Bika.coa aproach is that if two renders run simultaneously before saving, they will have the same ID in the PDF.