Skip to content

Commit

Permalink
[16.0][FIX] document_page_tag: Use api.model_create_multi
Browse files Browse the repository at this point in the history
   Using decorator api.model_create_multi for create
method in document_page_tag model
  • Loading branch information
anusriNPS committed Jul 16, 2024
1 parent b1ef710 commit d83332f
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions document_page_tag/models/document_page_tag.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,11 @@ 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)
for vals in vals_list:
existing = self.search([("name", "=ilike", vals["name"])], limit=1)
if existing:
return existing
return super().create(vals_list)

0 comments on commit d83332f

Please sign in to comment.