mirror of
https://github.com/OCA/reporting-engine.git
synced 2025-02-16 16:30:38 +02:00
[IMP] base_comment_template: Code refactorization
This commit is contained in:
committed by
Víctor Martínez
parent
2c3e562dde
commit
e1011fa519
@@ -16,34 +16,6 @@ class CommentTemplate(models.AbstractModel):
|
||||
"in reports based on created comment templates"
|
||||
)
|
||||
|
||||
base_comment_template_ids = fields.Many2many(
|
||||
comodel_name="base.comment.template",
|
||||
string="Comment templates",
|
||||
compute="_compute_base_comment_template_ids",
|
||||
search="_search_follower_partners",
|
||||
help="Templates that can be included in your reports",
|
||||
)
|
||||
|
||||
def _compute_base_comment_template_ids(self):
|
||||
company_id = self.env.company.id
|
||||
present_model_id = self.env["ir.model"].search([("name", "=", self._name)])
|
||||
templates = (
|
||||
self.env["base.comment.template"]
|
||||
.sudo()
|
||||
.search(
|
||||
[
|
||||
("model_ids", "in", present_model_id.id),
|
||||
"|",
|
||||
("company_id", "=", company_id),
|
||||
("company_id", "=", False),
|
||||
]
|
||||
)
|
||||
)
|
||||
# using read() below is much faster than followers.mapped('res_id')
|
||||
model_mako_templates_ids = templates.mapped("id")
|
||||
for record in self:
|
||||
record.base_comment_template_ids = record.id in model_mako_templates_ids
|
||||
|
||||
def get_comment_template(
|
||||
self, position="before_lines", company_id=False, partner_id=False
|
||||
):
|
||||
|
||||
Reference in New Issue
Block a user