diff --git a/base_comment_template/models/base_comment_template.py b/base_comment_template/models/base_comment_template.py index 316c2201b1..49c5a9d46e 100644 --- a/base_comment_template/models/base_comment_template.py +++ b/base_comment_template/models/base_comment_template.py @@ -120,6 +120,8 @@ def name_get(self): def _search_model_ids(self, operator, value): # We cannot use model_ids.model in search() method to avoid recursion. allowed_items = ( - self.sudo().search([]).filtered(lambda x: x.model_ids.model == value) + self.sudo() + .search([]) + .filtered(lambda x: value in x.model_ids.mapped("model")) ) return [("id", "in", allowed_items.ids)] diff --git a/base_comment_template/models/comment_template.py b/base_comment_template/models/comment_template.py index 2e7f184075..64afe3980a 100644 --- a/base_comment_template/models/comment_template.py +++ b/base_comment_template/models/comment_template.py @@ -24,7 +24,7 @@ class CommentTemplate(models.AbstractModel): compute_sudo=True, comodel_name="base.comment.template", string="Comment Template", - domain=lambda self: [("model_ids", "=", self._name)], + domain=lambda self: [("model_ids", "in", self._name)], store=True, readonly=False, ) @@ -32,7 +32,7 @@ class CommentTemplate(models.AbstractModel): @api.depends(_comment_template_partner_field_name) def _compute_comment_template_ids(self): template_model = self.env["base.comment.template"] - template_domain = template_model._search_model_ids("=", self._name) + template_domain = template_model._search_model_ids("in", self._name) for record in self: partner = record[self._comment_template_partner_field_name] record.comment_template_ids = [(5,)]