From 9560e9fa0613808b01d2772e1c8d4bbccb17bb1b Mon Sep 17 00:00:00 2001 From: Miquel Rosell Date: Wed, 27 May 2026 12:05:46 +0200 Subject: [PATCH] [FIX] document_page_tag: convert create to api.model_create_multi --- document_page_tag/models/document_page_tag.py | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/document_page_tag/models/document_page_tag.py b/document_page_tag/models/document_page_tag.py index cb5bf89b82e..d4ffed232e1 100644 --- a/document_page_tag/models/document_page_tag.py +++ b/document_page_tag/models/document_page_tag.py @@ -15,10 +15,14 @@ class DocumentPageTag(models.Model): ("unique_name", "unique(name)", "Tags must be unique"), ] - @api.model - def create(self, vals): + @api.model_create_multi + def create(self, vals_list): """Be nice when trying to create duplicates""" - existing = self.search([("name", "=ilike", vals["name"])], limit=1) - if existing: - return existing - return super().create(vals) + result = self.env["document.page.tag"] + for vals in vals_list: + existing = self.search([("name", "=ilike", vals.get("name", ""))], limit=1) + if existing: + result |= existing + else: + result |= super().create(vals) + return result