From 642449421c2ea73f909649c5e328827a9ce9d422 Mon Sep 17 00:00:00 2001 From: Nikos Tsirintanis Date: Tue, 18 Nov 2025 10:38:45 +0100 Subject: [PATCH] [16.0][FIX] project_task_description_template: no duplicate description on template onchange --- .../models/project_task.py | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/project_task_description_template/models/project_task.py b/project_task_description_template/models/project_task.py index 3b40f1b677..4a42eb5c1d 100644 --- a/project_task_description_template/models/project_task.py +++ b/project_task_description_template/models/project_task.py @@ -13,6 +13,15 @@ class ProjectTask(models.Model): @api.onchange("description_template_id") def _onchange_description_template_id(self): - if self.description_template_id: - description = self.description if self.description else "" - self.description = description + self.description_template_id.description + for task in self: + if not task.description_template_id: + continue + template_text = task.description_template_id.description or "" + # fields are html, str and compare them + template_text = str(template_text) + current = task.description or "" + current = str(current) + # Avoid duplicating the same template content ANYWHERE in the description + if current == template_text or template_text in current: + continue + task.description = current + template_text