Cover with a mocked Docuseal API (shared ``DocusealApiMockMixin`` capturing every request): - field value conversion matrix in ``_create_submissions``: char, selection label, many2one/many2many display names, date formatting, empty value left editable while set values are locked - payload structure and one-submission-per-partner behavior - draft submissions created with ``send_email`` disabled - API URL trailing slash stripped - server action creation is idempotent Assisted-By: GLM-5.3-Flash
39 lines
1.3 KiB
Python
39 lines
1.3 KiB
Python
from odoo.tests import TransactionCase
|
|
|
|
|
|
class TestServerAction(TransactionCase):
|
|
"""Lifecycle of the generated contextual server action."""
|
|
|
|
def test_unlink_removes_server_action(self):
|
|
"""Deleting a template removes its generated server action,
|
|
instead of leaving an orphaned action browsing a dead record."""
|
|
template = self.env["docuseal.template"].create({
|
|
"name": "Contract",
|
|
"template_id": 123,
|
|
})
|
|
template.action_create_server_action()
|
|
action = template.server_action_id
|
|
self.assertTrue(action.exists())
|
|
|
|
template.unlink()
|
|
self.assertFalse(action.exists())
|
|
|
|
def test_create_server_action_is_idempotent(self):
|
|
"""Creating the contextual action twice updates the existing
|
|
action instead of generating a duplicate."""
|
|
template = self.env["docuseal.template"].create({
|
|
"name": "Contract",
|
|
"template_id": 456,
|
|
})
|
|
template.action_create_server_action()
|
|
first_action = template.server_action_id
|
|
template.action_create_server_action()
|
|
|
|
self.assertEqual(template.server_action_id, first_action)
|
|
self.assertEqual(
|
|
self.env["ir.actions.server"].search_count([
|
|
("name", "=", "Request signature (Contract)"),
|
|
]),
|
|
1,
|
|
)
|