Skip to content

Commit

Permalink
[MIG] base_comment_template: Migration to 18.0
Browse files Browse the repository at this point in the history
  • Loading branch information
yankinmax committed Jan 8, 2025
1 parent 7a2539b commit 4b95fcf
Show file tree
Hide file tree
Showing 10 changed files with 27 additions and 66 deletions.
10 changes: 5 additions & 5 deletions base_comment_template/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@ Base Comments Templates
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
:alt: License: AGPL-3
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Freporting--engine-lightgray.png?logo=github
:target: https://github.com/OCA/reporting-engine/tree/17.0/base_comment_template
:target: https://github.com/OCA/reporting-engine/tree/18.0/base_comment_template
:alt: OCA/reporting-engine
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/reporting-engine-17-0/reporting-engine-17-0-base_comment_template
:target: https://translation.odoo-community.org/projects/reporting-engine-18-0/reporting-engine-18-0-base_comment_template
:alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png
:target: https://runboat.odoo-community.org/builds?repo=OCA/reporting-engine&target_branch=17.0
:target: https://runboat.odoo-community.org/builds?repo=OCA/reporting-engine&target_branch=18.0
:alt: Try me on Runboat

|badge1| |badge2| |badge3| |badge4| |badge5|
Expand Down Expand Up @@ -140,7 +140,7 @@ Bug Tracker
Bugs are tracked on `GitHub Issues <https://github.com/OCA/reporting-engine/issues>`_.
In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us to smash it by providing a detailed and welcomed
`feedback <https://github.com/OCA/reporting-engine/issues/new?body=module:%20base_comment_template%0Aversion:%2017.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
`feedback <https://github.com/OCA/reporting-engine/issues/new?body=module:%20base_comment_template%0Aversion:%2018.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.

Do not contact contributors directly about support or help with technical issues.

Expand Down Expand Up @@ -199,6 +199,6 @@ OCA, or the Odoo Community Association, is a nonprofit organization whose
mission is to support the collaborative development of Odoo features and
promote its widespread use.

This module is part of the `OCA/reporting-engine <https://github.com/OCA/reporting-engine/tree/17.0/base_comment_template>`_ project on GitHub.
This module is part of the `OCA/reporting-engine <https://github.com/OCA/reporting-engine/tree/18.0/base_comment_template>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
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": "17.0.1.0.0",
"version": "18.0.1.0.0",
"category": "Reporting",
"website": "https://github.com/OCA/reporting-engine",
"author": "Camptocamp, Odoo Community Association (OCA)",
Expand Down
17 changes: 0 additions & 17 deletions base_comment_template/migrations/16.0.1.0.0/post-migration.py

This file was deleted.

27 changes: 0 additions & 27 deletions base_comment_template/migrations/16.0.1.1.0/pre-migration.py

This file was deleted.

9 changes: 5 additions & 4 deletions base_comment_template/models/base_comment_template.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# Copyright 2020 NextERP Romania SRL
# Copyright 2021-2022 Tecnativa - Víctor Martínez
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from odoo import _, api, fields, models
from odoo import Command, api, fields, models
from odoo.exceptions import ValidationError


Expand Down Expand Up @@ -48,7 +48,6 @@ class BaseCommentTemplate(models.Model):
column1="base_comment_template_id",
column2="res_partner_id",
string="Partner",
readonly=True,
help="If set, the comment template will be available only for the selected "
"partner.",
)
Expand Down Expand Up @@ -104,7 +103,7 @@ def _compute_model_ids(self):
models = im_model.browse()
if item.models:
models = self._get_ir_model_items(item.models.split(","))
item.model_ids = [(6, 0, models.ids)]
item.model_ids = [Command.set(models.ids)]

@api.constrains("models")
def check_models(self):
Expand All @@ -113,7 +112,9 @@ def check_models(self):
models = item.models.split(",")
res = self._get_ir_model_items(item.models.split(","))
if not res or len(res) != len(models):
raise ValidationError(_("Some model (%s) not found") % item.models)
raise ValidationError(
self.env._(f"Some model ({item.models}) not found")
)

@api.depends("position", "model_ids")
def _compute_display_name(self):
Expand Down
4 changes: 2 additions & 2 deletions base_comment_template/models/comment_template.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
import markupsafe

from odoo import api, fields, models
from odoo import Command, api, fields, models
from odoo.osv import expression
from odoo.tools.safe_eval import safe_eval

Expand Down Expand Up @@ -49,7 +49,7 @@ def _compute_comment_template_ids(self):
for template in templates:
domain = safe_eval(template.domain)
if not domain or record.filtered_domain(domain):
record.comment_template_ids = [(4, template.id)]
record.comment_template_ids = [Command.link(template.id)]

def render_comment(self, comment, engine=False, add_context=None, options=None):
self.ensure_one()
Expand Down
6 changes: 3 additions & 3 deletions base_comment_template/static/description/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,7 @@ <h1 class="title">Base Comments Templates</h1>
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:3b5eb88dbd79b1149e679ff90f3a24b61a1f07af046693635b7fc3b597479aba
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
<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/licence-AGPL--3-blue.png" /></a> <a class="reference external image-reference" href="https://github.com/OCA/reporting-engine/tree/17.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-17-0/reporting-engine-17-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=17.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
<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/licence-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
documents. The comment templates can be defined like make templates, so
you can use variables from linked models.</p>
Expand Down Expand Up @@ -484,7 +484,7 @@ <h1><a class="toc-backref" href="#toc-entry-3">Bug Tracker</a></h1>
<p>Bugs are tracked on <a class="reference external" href="https://github.com/OCA/reporting-engine/issues">GitHub Issues</a>.
In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us to smash it by providing a detailed and welcomed
<a class="reference external" href="https://github.com/OCA/reporting-engine/issues/new?body=module:%20base_comment_template%0Aversion:%2017.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
<a class="reference external" href="https://github.com/OCA/reporting-engine/issues/new?body=module:%20base_comment_template%0Aversion:%2018.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
<p>Do not contact contributors directly about support or help with technical issues.</p>
</div>
<div class="section" id="credits">
Expand Down Expand Up @@ -540,7 +540,7 @@ <h2><a class="toc-backref" href="#toc-entry-7">Maintainers</a></h2>
<p>OCA, or the Odoo Community Association, is a nonprofit organization whose
mission is to support the collaborative development of Odoo features and
promote its widespread use.</p>
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/reporting-engine/tree/17.0/base_comment_template">OCA/reporting-engine</a> project on GitHub.</p>
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/reporting-engine/tree/18.0/base_comment_template">OCA/reporting-engine</a> project on GitHub.</p>
<p>You are welcome to contribute. To learn how please visit <a class="reference external" href="https://odoo-community.org/page/Contribute">https://odoo-community.org/page/Contribute</a>.</p>
</div>
</div>
Expand Down
4 changes: 2 additions & 2 deletions base_comment_template/tests/test_base_comment_template.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ def test_partner_template_domain(self):
(4, self.before_template_id.id),
(4, self.after_template_id.id),
]
self.before_template_id.domain = "[('id', 'in', %s)]" % self.user.ids
self.before_template_id.domain = f"[('id', 'in', {self.user.ids})]"
self.assertTrue(
self.before_template_id in self.partner2_id.base_comment_template_ids
)
Expand All @@ -114,7 +114,7 @@ def test_partner_template_domain(self):
)

def test_render_comment_text(self):
expected_text = "Test comment render %s" % self.user.name
expected_text = f"Test comment render {self.user.name}"
self.before_template_id.text = "Test comment render {{object.name}}"
with self.with_user(self.user.login):
self.assertEqual(
Expand Down
10 changes: 7 additions & 3 deletions base_comment_template/views/base_comment_template_view.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<field name="name">base.comment.template.search</field>
<field name="model">base.comment.template</field>
<field name="arch" type="xml">
<tree>
<list>
<field name="sequence" widget="handle" />
<field name="name" />
<field name="position" />
Expand All @@ -13,7 +13,7 @@
<field name="models" />
<field name="model_ids" groups="base.group_erp_manager" />
<field name="domain" />
</tree>
</list>
</field>
</record>
<record model="ir.ui.view" id="view_base_comment_template_search">
Expand Down Expand Up @@ -70,7 +70,11 @@
/>
<field name="domain" />
<field name="models" />
<field name="partner_ids" widget="many2many_tags" />
<field
name="partner_ids"
widget="many2many_tags"
readonly="1"
/>
<field name="engine" groups="base.group_no_one" />
</group>
</group>
Expand Down
4 changes: 2 additions & 2 deletions base_comment_template/views/res_partner_view.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
nolabel="1"
context="{'comment_template_model_display': True}"
>
<tree>
<list>
<field name="display_name" string="Name" />
<field name="position" />
<field
Expand All @@ -19,7 +19,7 @@
/>
<field name="model_ids" />
<field name="domain" />
</tree>
</list>
</field>
</page>
</page>
Expand Down

0 comments on commit 4b95fcf

Please sign in to comment.