Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[16.0][FIX] base_comment_template: search when multiple models in a template #780

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -119,6 +119,8 @@ def name_get(self):
def _search_model_ids(self, operator, value):
# We cannot use model_ids.model in search() method to avoid access errors
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
Loading