[IMP] document_page: warning multi create

This commit is contained in:
Kevin Luna 2025-03-21 12:15:15 +01:00
parent c0d3956efd
commit 246867013d

View File

@ -191,19 +191,24 @@ class DocumentPage(models.Model):
)
return super().copy(default=default)
@api.model
def create(self, vals):
@api.model_create_multi
def create(self, vals_list):
"""Automatically make the category followers follow the new page"""
res = super().create(vals)
records = super().create(vals_list)
if res.type == "content" and res.parent_id and res.parent_id.type == "category":
category = res.parent_id
category_followers = category.message_partner_ids.ids
for res in records:
if (
res.type == "content"
and res.parent_id
and res.parent_id.type == "category"
):
category = res.parent_id
category_followers = category.message_partner_ids.ids
if category_followers:
res.message_subscribe(partner_ids=category_followers)
if category_followers:
res.message_subscribe(partner_ids=category_followers)
return res
return records
def message_subscribe(self, partner_ids, subtype_ids=None):
res = super().message_subscribe(partner_ids, subtype_ids)