mirror of
https://github.com/OCA/reporting-engine.git
synced 2025-02-16 16:30:38 +02:00
[FIX] base_comment_template: Consider multi-company and partners
In a multi-company context, if you put a template with company_id set, this template is trying to be assigned to any document, no matter which company it belongs, as it runs in a sudo environment, or at least, you can have several companies seen at the same time. We add the company discriminant for avoiding this problem. Furthermore, the previous code was adding a domain where the right part may be `False` with the operator `in`, provoking an unexpected behavior in the search. This has been fixed stating directly the expected domain. TT42591
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
# Copyright 2020 NextERP Romania SRL
|
||||
# Copyright 2021 Tecnativa - Víctor Martínez
|
||||
# Copyright 2023 Tecnativa - Pedro M. Baeza
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
|
||||
from odoo.tests import common
|
||||
from odoo.tools.misc import mute_logger
|
||||
@@ -18,14 +19,12 @@ class TestCommentTemplate(common.SavepointCase):
|
||||
cls.partner_id = cls.env.ref("base.res_partner_12")
|
||||
cls.partner2_id = cls.env.ref("base.res_partner_10")
|
||||
cls.ResPartnerTitle = cls.env["res.partner.title"]
|
||||
cls.main_company = cls.env.ref("base.main_company")
|
||||
cls.company = cls.env["res.company"].create({"name": "Test company"})
|
||||
cls.before_template_id = cls.env["base.comment.template"].create(
|
||||
{
|
||||
"name": "Top template",
|
||||
"text": "Text before lines",
|
||||
"model_ids": [(6, 0, cls.user_obj.ids)],
|
||||
"company_id": cls.company.id,
|
||||
"company_id": False,
|
||||
}
|
||||
)
|
||||
cls.after_template_id = cls.env["base.comment.template"].create(
|
||||
@@ -34,13 +33,9 @@ class TestCommentTemplate(common.SavepointCase):
|
||||
"position": "after_lines",
|
||||
"text": "Text after lines",
|
||||
"model_ids": [(6, 0, cls.user_obj.ids)],
|
||||
"company_id": cls.company.id,
|
||||
"company_id": False,
|
||||
}
|
||||
)
|
||||
cls.user.partner_id.base_comment_template_ids = [
|
||||
(4, cls.before_template_id.id),
|
||||
(4, cls.after_template_id.id),
|
||||
]
|
||||
|
||||
@classmethod
|
||||
def tearDownClass(cls):
|
||||
|
||||
Reference in New Issue
Block a user