[FIX] docuseal_signing: harden template copies, API errors and emails
Some checks failed
pre-commit / pre-commit (pull_request) Failing after 1m31s
tests / test (pull_request) Successful in 52s

- Do not copy the contextual action nor the submitter role with a
  template: a copy sharing the action would rewrite or delete the
  original's.
- Make the template ID read-only once fetched from Docuseal: another
  Docuseal template needs a new entry.
- Report an invalid API URL or token, an unexpected (non-JSON) response
  and a connection dropped mid-response as a readable UserError.
- Refuse to email a signature request to contacts without a valid email
  address (email_normalize), before any call to Docuseal.
- Stop logging the field values and the Docuseal response, which hold
  personal data and the signing links.
- Prevent adding mapping lines by hand: they come from Docuseal only.

Assisted-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-09 17:35:19 +01:00
parent 87653552b1
commit fddc2e5c4b
7 changed files with 238 additions and 27 deletions

View File

@@ -98,3 +98,25 @@ class TestServerAction(DocusealApiMockMixin, TransactionCase):
):
self._run_action(template, partners, self.env.user)
self.assertFalse(self.requests)
def test_copy_does_not_share_action_or_role(self):
"""A duplicated template gets neither the contextual action nor
the role of the original, so it cannot rewrite or delete them."""
template = self.env["docuseal.template"].create({
"name": "Contract",
"template_id": 791,
})
template.submitter_role_id = self.env["docuseal.template.role"].create({
"template_id": template.id,
"name": "Signer",
})
template.action_create_server_action()
action = template.server_action_id
duplicate = template.copy()
self.assertFalse(duplicate.server_action_id)
self.assertFalse(duplicate.submitter_role_id)
duplicate.unlink()
self.assertTrue(action.exists())
self.assertEqual(template.server_action_id, action)