[FIX] base_comment_template: Add models text field to prevent error from ir.model model

TT40209
This commit is contained in:
Víctor Martínez
2022-11-02 08:52:09 +01:00
parent 8dfa82089f
commit d9d2ef5b27
8 changed files with 142 additions and 32 deletions

View File

@@ -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,