Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 | <a href='https://github.com/legalsylvain'><img src='https://github.com/legalsylvain.png' width='32' height='32' style='border-radius:50%;' alt='legalsylvain'/></a> | BI Views builder, based on Materialized or Normal SQL Views
[pdf_xml_attachment](pdf_xml_attachment/) | 18.0.1.0.0 | <a href='https://github.com/simahawk'><img src='https://github.com/simahawk.png' width='32' height='32' style='border-radius:50%;' alt='simahawk'/></a> <a href='https://github.com/alexis-via'><img src='https://github.com/alexis-via.png' width='32' height='32' style='border-radius:50%;' alt='alexis-via'/></a> | Provides helpers to work w/ PDFs and XML attachments
[report_context](report_context/) | 18.0.1.0.0 | | Adding context to reports
Expand Down
2 changes: 1 addition & 1 deletion base_comment_template/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion base_comment_template/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)",
Expand Down
2 changes: 1 addition & 1 deletion base_comment_template/static/description/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,7 @@ <h1>Base Comments Templates</h1>
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:0620ad5d4c8445203bc9d9f3e29873c70febf5c945424fbcd89971227b0767d7
!! source digest: sha256:05f221f43e40206172e02b354bd65e60537a0b6e9727ec4f52dc5a2b958c8fe7
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
<p><a class="reference external image-reference" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external image-reference" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/license-AGPL--3-blue.png" /></a> <a class="reference external image-reference" href="https://github.com/OCA/reporting-engine/tree/18.0/base_comment_template"><img alt="OCA/reporting-engine" src="https://img.shields.io/badge/github-OCA%2Freporting--engine-lightgray.png?logo=github" /></a> <a class="reference external image-reference" href="https://translation.odoo-community.org/projects/reporting-engine-18-0/reporting-engine-18-0-base_comment_template"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external image-reference" href="https://runboat.odoo-community.org/builds?repo=OCA/reporting-engine&amp;target_branch=18.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
<p>Add a new mixin class to define templates of comments to print on
Expand Down
22 changes: 0 additions & 22 deletions base_comment_template/tests/fake_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
Expand Down
45 changes: 22 additions & 23 deletions base_comment_template/tests/test_base_comment_template.py
Original file line number Diff line number Diff line change
@@ -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")
Expand All @@ -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")
Expand Down
Loading