[MIG] base_comment_template: Migration to 15.0

This commit is contained in:
Jesús Alan Ramos Rodríguez
2022-04-26 14:04:46 -05:00
committed by Maksym Yankin
parent 735a2c9d63
commit a624f08f5f
9 changed files with 29 additions and 75 deletions

View File

@@ -14,13 +14,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/14.0/base_comment_template
:target: https://github.com/OCA/reporting-engine/tree/15.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-14-0/reporting-engine-14-0-base_comment_template
:target: https://translation.odoo-community.org/projects/reporting-engine-15-0/reporting-engine-15-0-base_comment_template
:alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png
:target: https://runbot.odoo-community.org/runbot/143/14.0
:target: https://runbot.odoo-community.org/runbot/143/15.0
:alt: Try me on Runbot
|badge1| |badge2| |badge3| |badge4| |badge5|
@@ -120,7 +120,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 smashing it by providing a detailed and welcomed
`feedback <https://github.com/OCA/reporting-engine/issues/new?body=module:%20base_comment_template%0Aversion:%2014.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:%2015.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.
@@ -158,6 +158,10 @@ Contributors
* Carlos Roca
* Víctor Martínez
* `Jarsa <https://www.jarsa.com>`_:
* Alan Ramos <alan.ramos@jarsa.com>
Maintainers
~~~~~~~~~~~
@@ -171,6 +175,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/14.0/base_comment_template>`_ project on GitHub.
This module is part of the `OCA/reporting-engine <https://github.com/OCA/reporting-engine/tree/15.0/base_comment_template>`_ project on GitHub.
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

View File

@@ -5,7 +5,7 @@
"name": "Base Comments Templates",
"summary": "Add conditional mako template to any report"
"on models that inherits comment.template.",
"version": "14.0.3.0.1",
"version": "15.0.1.0.0",
"category": "Reporting",
"website": "https://github.com/OCA/reporting-engine",
"author": "Camptocamp, Odoo Community Association (OCA)",

View File

@@ -1,29 +0,0 @@
# Copyright 2021 Tecnativa - Víctor Martínez
# Copyright 2021 Tecnativa - Pedro M. Baeza
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
from openupgradelib import openupgrade
from odoo.tools import parse_version
@openupgrade.migrate()
def migrate(env, version):
if parse_version(version) == parse_version("14.0.1.0.0"):
openupgrade.logged_query(
env.cr,
"""
INSERT INTO base_comment_template_res_partner_rel
(res_partner_id, base_comment_template_id)
SELECT SPLIT_PART(ip.res_id, ',', 2)::int AS res_partner_id,
SPLIT_PART(ip.value_reference, ',', 2)::int AS base_comment_template_id
FROM ir_property ip
JOIN ir_model_fields imf ON ip.fields_id = imf.id
JOIN res_partner rp ON rp.id = SPLIT_PART(ip.res_id, ',', 2)::int
JOIN base_comment_template bct
ON bct.id = SPLIT_PART(ip.value_reference, ',', 2)::int
WHERE imf.name = 'property_comment_template_id'
AND imf.model = 'res.partner'
AND ip.res_id IS NOT NULL
ON CONFLICT DO NOTHING
""",
)

View File

@@ -1,30 +0,0 @@
# Copyright 2021 Tecnativa - Víctor Martínez
# Copyright 2021 Tecnativa - Pedro M: Baeza
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
from openupgradelib import openupgrade
from odoo.tools import parse_version
field_renames = [
("base.comment.template", "base_comment_template", "priority", "sequence"),
]
@openupgrade.migrate()
def migrate(env, version):
if parse_version(version) == parse_version("14.0.1.0.0"):
openupgrade.rename_fields(env, field_renames)
if openupgrade.table_exists(env.cr, "base_comment_template_res_partner_rel"):
# Swap column names, as they were incorrect
env.cr.execute(
"ALTER TABLE base_comment_template_res_partner_rel "
"RENAME base_comment_template_id TO temp"
)
env.cr.execute(
"ALTER TABLE base_comment_template_res_partner_rel "
"RENAME res_partner_id TO base_comment_template_id"
)
env.cr.execute(
"ALTER TABLE base_comment_template_res_partner_rel "
"RENAME temp TO res_partner_id"
)

View File

@@ -22,7 +22,6 @@ class BaseCommentTemplate(models.Model):
help="This field allows to select the position of the comment on reports.",
)
name = fields.Char(
string="Name",
translate=True,
required=True,
help="Name/description of this comment template",

View File

@@ -20,3 +20,7 @@
* Carlos Roca
* Víctor Martínez
* `Jarsa <https://www.jarsa.com>`_:
* Alan Ramos <alan.ramos@jarsa.com>

View File

@@ -3,7 +3,7 @@
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="generator" content="Docutils 0.15.1: http://docutils.sourceforge.net/" />
<meta name="generator" content="Docutils: http://docutils.sourceforge.net/" />
<title>Base Comments Templates</title>
<style type="text/css">
@@ -367,7 +367,7 @@ ul.auto-toc {
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
<p><a class="reference external" 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" 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" href="https://github.com/OCA/reporting-engine/tree/14.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" href="https://translation.odoo-community.org/projects/reporting-engine-14-0/reporting-engine-14-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" href="https://runbot.odoo-community.org/runbot/143/14.0"><img alt="Try me on Runbot" src="https://img.shields.io/badge/runbot-Try%20me-875A7B.png" /></a></p>
<p><a class="reference external" 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" 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" href="https://github.com/OCA/reporting-engine/tree/15.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" href="https://translation.odoo-community.org/projects/reporting-engine-15-0/reporting-engine-15-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" href="https://runbot.odoo-community.org/runbot/143/15.0"><img alt="Try me on Runbot" src="https://img.shields.io/badge/runbot-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>
<p>Two positions are available for the comments:</p>
@@ -463,7 +463,7 @@ mail.render.mixin with parameters:</p>
<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 smashing 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:%2014.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:%2015.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">
@@ -500,6 +500,10 @@ If you spotted it first, help us smashing it by providing a detailed and welcome
<li>Víctor Martínez</li>
</ul>
</li>
<li><a class="reference external" href="https://www.jarsa.com">Jarsa</a>:<ul>
<li>Alan Ramos &lt;<a class="reference external" href="mailto:alan.ramos&#64;jarsa.com">alan.ramos&#64;jarsa.com</a>&gt;</li>
</ul>
</li>
</ul>
</div>
<div class="section" id="maintainers">
@@ -509,7 +513,7 @@ If you spotted it first, help us smashing it by providing a detailed and welcome
<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/14.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/15.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>

View File

@@ -7,7 +7,7 @@ from odoo.tools.misc import mute_logger
from .fake_models import ResUsers, setup_test_model, teardown_test_model
class TestCommentTemplate(common.SavepointCase):
class TestCommentTemplate(common.TransactionCase):
@classmethod
def setUpClass(cls):
super().setUpClass()
@@ -45,7 +45,7 @@ class TestCommentTemplate(common.SavepointCase):
@classmethod
def tearDownClass(cls):
teardown_test_model(cls.env, ResUsers)
super(TestCommentTemplate, cls).tearDownClass()
return super(TestCommentTemplate, cls).tearDownClass()
def test_template_name_get(self):
self.assertEqual(
@@ -110,7 +110,9 @@ class TestCommentTemplate(common.SavepointCase):
)
# Adding translated terms
ctx = dict(lang="ro_RO")
partner_title.with_context(ctx).write({"name": "Ambasador", "shortcut": "Amb."})
partner_title.with_context(**ctx).write(
{"name": "Ambasador", "shortcut": "Amb."}
)
self.user.partner_id.title = partner_title
self.before_template_id.text = "Test comment render ${object.title.name}"
@@ -121,7 +123,7 @@ class TestCommentTemplate(common.SavepointCase):
self.user.render_comment(self.before_template_id), expected_en_text
)
self.assertEqual(
self.user.with_context(ctx).render_comment(self.before_template_id),
self.user.with_context(**ctx).render_comment(self.before_template_id),
expected_ro_text,
)

View File

@@ -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 string="Comment Templates">
<tree>
<field name="sequence" widget="handle" />
<field name="name" />
<field name="position" />