mirror of
https://github.com/OCA/reporting-engine.git
synced 2025-02-16 16:30:38 +02:00
[FIX] base_comment_template: Add models text field to prevent error from ir.model model
TT40209
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
# Copyright 2021 Tecnativa - Víctor Martínez
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
|
||||
from odoo import Command
|
||||
from odoo.exceptions import ValidationError
|
||||
from odoo.tests import common
|
||||
from odoo.tools.misc import mute_logger
|
||||
|
||||
@@ -25,7 +26,7 @@ class TestCommentTemplate(common.TransactionCase):
|
||||
{
|
||||
"name": "Top template",
|
||||
"text": "Text before lines",
|
||||
"model_ids": [(6, 0, cls.user_obj.ids)],
|
||||
"models": cls.user_obj.model,
|
||||
"company_id": cls.company.id,
|
||||
}
|
||||
)
|
||||
@@ -34,7 +35,7 @@ class TestCommentTemplate(common.TransactionCase):
|
||||
"name": "Bottom template",
|
||||
"position": "after_lines",
|
||||
"text": "Text after lines",
|
||||
"model_ids": [(6, 0, cls.user_obj.ids)],
|
||||
"models": cls.user_obj.model,
|
||||
"company_id": cls.company.id,
|
||||
}
|
||||
)
|
||||
@@ -48,6 +49,27 @@ class TestCommentTemplate(common.TransactionCase):
|
||||
teardown_test_model(cls.env, ResUsers)
|
||||
return super(TestCommentTemplate, cls).tearDownClass()
|
||||
|
||||
def test_template_model_ids(self):
|
||||
self.assertIn(
|
||||
self.user_obj.model, self.before_template_id.mapped("model_ids.model")
|
||||
)
|
||||
self.assertEqual(len(self.before_template_id.model_ids), 1)
|
||||
self.assertIn(
|
||||
self.user_obj.model, self.after_template_id.mapped("model_ids.model")
|
||||
)
|
||||
self.assertEqual(len(self.after_template_id.model_ids), 1)
|
||||
|
||||
def test_template_models_constrains(self):
|
||||
with self.assertRaises(ValidationError):
|
||||
self.env["base.comment.template"].create(
|
||||
{
|
||||
"name": "Custom template",
|
||||
"text": "Text",
|
||||
"models": "incorrect.model",
|
||||
"company_id": self.company.id,
|
||||
}
|
||||
)
|
||||
|
||||
def test_template_name_get(self):
|
||||
self.assertEqual(
|
||||
self.before_template_id.display_name,
|
||||
|
||||
Reference in New Issue
Block a user