diff --git a/README.md b/README.md index 39f544d899..917555817a 100644 --- a/README.md +++ b/README.md @@ -21,7 +21,7 @@ Available addons ---------------- addon | version | maintainers | summary --- | --- | --- | --- -[base_comment_template](base_comment_template/) | 18.0.1.1.1 | | Add conditional mako template to any reporton models that inherits comment.template. +[base_comment_template](base_comment_template/) | 18.0.1.1.2 | | Add conditional mako template to any reporton models that inherits comment.template. [bi_sql_editor](bi_sql_editor/) | 18.0.1.0.4 | legalsylvain | BI Views builder, based on Materialized or Normal SQL Views [pdf_xml_attachment](pdf_xml_attachment/) | 18.0.1.0.0 | simahawk alexis-via | Provides helpers to work w/ PDFs and XML attachments [report_context](report_context/) | 18.0.1.0.0 | | Adding context to reports diff --git a/base_comment_template/README.rst b/base_comment_template/README.rst index 642c36e379..9e2bd00e03 100644 --- a/base_comment_template/README.rst +++ b/base_comment_template/README.rst @@ -11,7 +11,7 @@ Base Comments Templates !! This file is generated by oca-gen-addon-readme !! !! changes will be overwritten. !! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - !! source digest: sha256:0620ad5d4c8445203bc9d9f3e29873c70febf5c945424fbcd89971227b0767d7 + !! source digest: sha256:05f221f43e40206172e02b354bd65e60537a0b6e9727ec4f52dc5a2b958c8fe7 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! .. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png diff --git a/base_comment_template/__manifest__.py b/base_comment_template/__manifest__.py index 0afc8587ee..279a6d620e 100644 --- a/base_comment_template/__manifest__.py +++ b/base_comment_template/__manifest__.py @@ -5,7 +5,7 @@ "name": "Base Comments Templates", "summary": "Add conditional mako template to any report" "on models that inherits comment.template.", - "version": "18.0.1.1.1", + "version": "18.0.1.1.2", "category": "Reporting", "website": "https://github.com/OCA/reporting-engine", "author": "Camptocamp, Odoo Community Association (OCA)", diff --git a/base_comment_template/static/description/index.html b/base_comment_template/static/description/index.html index 0e39821a9c..fac38305a7 100644 --- a/base_comment_template/static/description/index.html +++ b/base_comment_template/static/description/index.html @@ -372,7 +372,7 @@

Base Comments Templates

!! This file is generated by oca-gen-addon-readme !! !! changes will be overwritten. !! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -!! source digest: sha256:0620ad5d4c8445203bc9d9f3e29873c70febf5c945424fbcd89971227b0767d7 +!! source digest: sha256:05f221f43e40206172e02b354bd65e60537a0b6e9727ec4f52dc5a2b958c8fe7 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->

Beta License: AGPL-3 OCA/reporting-engine Translate me on Weblate Try me on Runboat

Add a new mixin class to define templates of comments to print on diff --git a/base_comment_template/tests/fake_models.py b/base_comment_template/tests/fake_models.py index 02ee0ca234..9ac818231f 100644 --- a/base_comment_template/tests/fake_models.py +++ b/base_comment_template/tests/fake_models.py @@ -6,28 +6,6 @@ from odoo import models -def setup_test_model(env, model_cls): - """Pass a test model class and initialize it. - - Courtesy of SBidoul from https://github.com/OCA/mis-builder :) - """ - model_cls._build_model(env.registry, env.cr) - env.registry.setup_models(env.cr) - env.registry.init_models( - env.cr, [model_cls._name], dict(env.context, update_custom_fields=True) - ) - - -def teardown_test_model(env, model_cls): - """Pass a test model class and deinitialize it. - - Courtesy of SBidoul from https://github.com/OCA/mis-builder :) - """ - if not getattr(model_cls, "_teardown_no_delete", False): - del env.registry.models[model_cls._name] - env.registry.setup_models(env.cr) - - class ResUsers(models.Model): _name = "res.users" _inherit = ["res.users", "comment.template"] diff --git a/base_comment_template/tests/test_base_comment_template.py b/base_comment_template/tests/test_base_comment_template.py index 1290f09a67..3f1b86445c 100644 --- a/base_comment_template/tests/test_base_comment_template.py +++ b/base_comment_template/tests/test_base_comment_template.py @@ -1,26 +1,19 @@ # Copyright 2020 NextERP Romania SRL # Copyright 2021 Tecnativa - Víctor Martínez # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). +from odoo_test_helper import FakeModelLoader + from odoo import Command from odoo.exceptions import ValidationError from odoo.tests import common from odoo.tools.misc import mute_logger -from .fake_models import ResUsers, setup_test_model, teardown_test_model - class TestCommentTemplate(common.TransactionCase): @classmethod def setUpClass(cls): super().setUpClass() - setup_test_model(cls.env, ResUsers) - res_users_model = cls.env.registry["res.users"] # Register the comment_template_ids field added by comment.template mixin - cls.classPatch( - res_users_model, - "comment_template_ids", - res_users_model.comment_template_ids, - ) cls.user_obj = cls.env.ref("base.model_res_users") cls.user = cls.env.ref("base.user_demo") cls.user2 = cls.env.ref("base.demo_user0") @@ -29,33 +22,39 @@ def setUpClass(cls): 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( + + def setUp(self): + super().setUp() + + self.loader = FakeModelLoader(self.env, self.__module__) + self.loader.backup_registry() + from .fake_models import ResUsers + + self.loader.update_registry((ResUsers,)) + self.addCleanup(self.loader.restore_registry) + + self.before_template_id = self.env["base.comment.template"].create( { "name": "Top template", "text": "Text before lines", - "models": cls.user_obj.model, - "company_id": cls.company.id, + "models": self.user_obj.model, + "company_id": self.company.id, } ) - cls.after_template_id = cls.env["base.comment.template"].create( + self.after_template_id = self.env["base.comment.template"].create( { "name": "Bottom template", "position": "after_lines", "text": "Text after lines", - "models": cls.user_obj.model, - "company_id": cls.company.id, + "models": self.user_obj.model, + "company_id": self.company.id, } ) - cls.user.partner_id.base_comment_template_ids = [ - (4, cls.before_template_id.id), - (4, cls.after_template_id.id), + self.user.partner_id.base_comment_template_ids = [ + (4, self.before_template_id.id), + (4, self.after_template_id.id), ] - @classmethod - def tearDownClass(cls): - teardown_test_model(cls.env, ResUsers) - return super().tearDownClass() - def test_template_model_ids(self): self.assertIn( self.user_obj.model, self.before_template_id.mapped("model_ids.model")