[IMP] docuseal_signing: keep the Docuseal field order in the mapping

Fields are now ordered as returned by the Docuseal API: a sequence
field (reorderable with drag & drop) is written by
``action_fetch_fields`` according to the API field order, so deleting
a mapping line and re-fetching restores the original order instead of
appending it at the end.

Also refresh the French catalog (new Sequence field, new help texts,
stale smart_search entries dropped).

Covered by a unit test reproducing the delete-then-refetch scenario.

Assisted-By: GLM-5.3-Flash
This commit is contained in:
2026-11-03 16:45:43 +01:00
parent b3d0f4b0d3
commit 77d556c14a
6 changed files with 84 additions and 10 deletions

View File

@@ -52,18 +52,23 @@ class DocusealTemplate(models.Model):
self.submitter_role = data["submitters"][0].get("name", "")
# Reconcile the field mapping with the Docuseal template instead of
# wiping it: existing mappings keep their res.partner field.
# wiping it: existing mappings keep their res.partner field and the
# sequence follows the field order returned by the Docuseal API.
existing = {
field.docuseal_field_name: field for field in self.field_ids
}
docuseal_names = [
f["name"] for f in data.get("fields", []) if f.get("name")
]
for name in docuseal_names:
if name not in existing:
for index, name in enumerate(docuseal_names):
field = existing.get(name)
if field:
field.sequence = index
else:
self.env["docuseal.template.field"].create({
"template_id": self.id,
"docuseal_field_name": name,
"sequence": index,
})
self.field_ids.filtered(
lambda field: field.docuseal_field_name not in docuseal_names

View File

@@ -4,6 +4,9 @@ from odoo import fields, models
class DocusealTemplateField(models.Model):
_name = "docuseal.template.field"
_description = "Docuseal Template Field"
_order = "sequence, id"
sequence = fields.Integer(default=10)
template_id = fields.Many2one(
comodel_name="docuseal.template",