Skip to content

Commit

Permalink
[FIX] base_comment_template: search when multiple models in a template
Browse files Browse the repository at this point in the history
  • Loading branch information
AaronHForgeFlow committed Jul 28, 2023
1 parent 0115fe4 commit 89e980e
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
4 changes: 3 additions & 1 deletion base_comment_template/models/base_comment_template.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)]
4 changes: 2 additions & 2 deletions base_comment_template/models/comment_template.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,15 @@ 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,
)

@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,)]
Expand Down

0 comments on commit 89e980e

Please sign in to comment.