From 85f9bc918e13985ac71b04bfcb4e368222dbd721 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=ADctor=20Mart=C3=ADnez?= Date: Tue, 13 Apr 2021 13:46:31 +0200 Subject: [PATCH] [IMP] base_comment_template: Adapt to 14.0 --- base_comment_template/README.rst | 12 ++++---- base_comment_template/__manifest__.py | 4 +-- .../migrations/13.0.1.0.0/pre-migration.py | 25 ---------------- .../migrations/13.0.2.0.0/pre-migration.py | 12 -------- .../migrations/13.0.3.0.0/pre-migration.py | 21 ------------- .../migrations/14.0.1.0.0/pre-migration.py | 26 ---------------- .../migrations/14.0.2.0.0/post-migration.py | 29 ++++++++++++++++++ .../migrations/14.0.2.0.0/pre-migration.py | 30 +++++++++++++++++++ .../models/base_comment_template.py | 3 +- .../static/description/index.html | 8 +++-- .../tests/test_base_comment_template.py | 9 +++--- 11 files changed, 78 insertions(+), 101 deletions(-) delete mode 100644 base_comment_template/migrations/13.0.1.0.0/pre-migration.py delete mode 100644 base_comment_template/migrations/13.0.2.0.0/pre-migration.py delete mode 100644 base_comment_template/migrations/13.0.3.0.0/pre-migration.py delete mode 100644 base_comment_template/migrations/14.0.1.0.0/pre-migration.py create mode 100644 base_comment_template/migrations/14.0.2.0.0/post-migration.py create mode 100644 base_comment_template/migrations/14.0.2.0.0/pre-migration.py diff --git a/base_comment_template/README.rst b/base_comment_template/README.rst index 11871f63..50a03023 100644 --- a/base_comment_template/README.rst +++ b/base_comment_template/README.rst @@ -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/13.0/base_comment_template + :target: https://github.com/OCA/reporting-engine/tree/14.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-13-0/reporting-engine-13-0-base_comment_template + :target: https://translation.odoo-community.org/projects/reporting-engine-14-0/reporting-engine-14-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/13.0 + :target: https://runbot.odoo-community.org/runbot/143/14.0 :alt: Try me on Runbot |badge1| |badge2| |badge3| |badge4| |badge5| @@ -107,7 +107,7 @@ Bug Tracker Bugs are tracked on `GitHub 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 `_. +`feedback `_. Do not contact contributors directly about support or help with technical issues. @@ -134,6 +134,7 @@ Contributors * `Druidoo `_: * Iván Todorovich +* Pierre Verkest * `NextERP Romania `_: @@ -142,6 +143,7 @@ Contributors * `Tecnativa `_: * Carlos Roca + * Víctor Martínez Maintainers ~~~~~~~~~~~ @@ -156,6 +158,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 `_ project on GitHub. +This module is part of the `OCA/reporting-engine `_ project on GitHub. You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/base_comment_template/__manifest__.py b/base_comment_template/__manifest__.py index 7765b277..25656977 100644 --- a/base_comment_template/__manifest__.py +++ b/base_comment_template/__manifest__.py @@ -3,9 +3,9 @@ { "name": "Base Comments Templates", - "summary": "Add conditional mako template to any report " + "summary": "Add conditional mako template to any report" "on models that inherits comment.template.", - "version": "14.0.1.0.0", + "version": "14.0.2.0.0", "category": "Reporting", "website": "https://github.com/OCA/reporting-engine", "author": "Camptocamp, Odoo Community Association (OCA)", diff --git a/base_comment_template/migrations/13.0.1.0.0/pre-migration.py b/base_comment_template/migrations/13.0.1.0.0/pre-migration.py deleted file mode 100644 index 3a875e8d..00000000 --- a/base_comment_template/migrations/13.0.1.0.0/pre-migration.py +++ /dev/null @@ -1,25 +0,0 @@ -# Copyright 2020 NextERP Romania SRL -# Copyright 2021 Tecnativa - Víctor Martínez -# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). -from openupgradelib import openupgrade - - -@openupgrade.migrate() -def migrate(env, version): - # Not tested - 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' - """, - ) diff --git a/base_comment_template/migrations/13.0.2.0.0/pre-migration.py b/base_comment_template/migrations/13.0.2.0.0/pre-migration.py deleted file mode 100644 index a80f06fc..00000000 --- a/base_comment_template/migrations/13.0.2.0.0/pre-migration.py +++ /dev/null @@ -1,12 +0,0 @@ -# Copyright 2021 Tecnativa - Víctor Martínez -# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). -from openupgradelib import openupgrade # pylint: disable=W7936 - -field_renames = [ - ("base.comment.template", "base_comment_template", "priority", "sequence"), -] - - -@openupgrade.migrate() -def migrate(env, version): - openupgrade.rename_fields(env, field_renames) diff --git a/base_comment_template/migrations/13.0.3.0.0/pre-migration.py b/base_comment_template/migrations/13.0.3.0.0/pre-migration.py deleted file mode 100644 index 2ed21069..00000000 --- a/base_comment_template/migrations/13.0.3.0.0/pre-migration.py +++ /dev/null @@ -1,21 +0,0 @@ -# Copyright 2021 Tecnativa - Pedro M: Baeza -# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). -from openupgradelib import openupgrade # pylint: disable=W7936 - - -@openupgrade.migrate() -def migrate(env, version): - 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" - ) diff --git a/base_comment_template/migrations/14.0.1.0.0/pre-migration.py b/base_comment_template/migrations/14.0.1.0.0/pre-migration.py deleted file mode 100644 index 8775e5dd..00000000 --- a/base_comment_template/migrations/14.0.1.0.0/pre-migration.py +++ /dev/null @@ -1,26 +0,0 @@ -# Copyright 2021 Tecnativa - Víctor Martínez -# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). -from openupgradelib import openupgrade - -field_renames = [ - ("base.comment.template", "base_comment_template", "priority", "sequence"), -] - - -@openupgrade.migrate() -def migrate(env, version): - # Not tested - 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 - WHERE imf.name = 'property_comment_template_id' - AND imf.model = 'res.partner' - """, - ) - openupgrade.rename_fields(env, field_renames) diff --git a/base_comment_template/migrations/14.0.2.0.0/post-migration.py b/base_comment_template/migrations/14.0.2.0.0/post-migration.py new file mode 100644 index 00000000..30414fe2 --- /dev/null +++ b/base_comment_template/migrations/14.0.2.0.0/post-migration.py @@ -0,0 +1,29 @@ +# 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 + """, + ) diff --git a/base_comment_template/migrations/14.0.2.0.0/pre-migration.py b/base_comment_template/migrations/14.0.2.0.0/pre-migration.py new file mode 100644 index 00000000..75933bfd --- /dev/null +++ b/base_comment_template/migrations/14.0.2.0.0/pre-migration.py @@ -0,0 +1,30 @@ +# 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" + ) diff --git a/base_comment_template/models/base_comment_template.py b/base_comment_template/models/base_comment_template.py index 1d6905af..6ae2e264 100644 --- a/base_comment_template/models/base_comment_template.py +++ b/base_comment_template/models/base_comment_template.py @@ -76,8 +76,7 @@ class BaseCommentTemplate(models.Model): ) def name_get(self): - """Redefine the name_get method to show the template name with the position. - """ + """Redefine the name_get method to show the template name with the position.""" res = [] for item in self: name = "{} ({})".format( diff --git a/base_comment_template/static/description/index.html b/base_comment_template/static/description/index.html index 886c2013..bc9c427a 100644 --- a/base_comment_template/static/description/index.html +++ b/base_comment_template/static/description/index.html @@ -367,7 +367,7 @@ ul.auto-toc { !! This file is generated by oca-gen-addon-readme !! !! changes will be overwritten. !! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! --> -

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

+

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

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.

Two positions are available for the comments:

@@ -448,7 +448,7 @@ If you create a new template with the same configuration (Model, Domain, Positio

Bugs are tracked on GitHub 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.

+feedback.

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

@@ -475,12 +475,14 @@ If you spotted it first, help us smashing it by providing a detailed and welcome
  • Iván Todorovich <ivan.todorovich@druidoo.io>
  • +
  • Pierre Verkest <pierreverkest84@gmail.com>
  • NextERP Romania:
  • Tecnativa:
    • Carlos Roca
    • +
    • Víctor Martínez
  • @@ -492,7 +494,7 @@ If you spotted it first, help us smashing it by providing a detailed and welcome

    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 project on GitHub.

    +

    This module is part of the OCA/reporting-engine project on GitHub.

    You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

    diff --git a/base_comment_template/tests/test_base_comment_template.py b/base_comment_template/tests/test_base_comment_template.py index c191546e..30ae71a5 100644 --- a/base_comment_template/tests/test_base_comment_template.py +++ b/base_comment_template/tests/test_base_comment_template.py @@ -7,9 +7,6 @@ from .fake_models import ResUsers, setup_test_model, teardown_test_model class TestCommentTemplate(common.SavepointCase): - at_install = False - post_install = True - @classmethod def setUpClass(cls): super().setUpClass() @@ -50,10 +47,12 @@ class TestCommentTemplate(common.SavepointCase): def test_template_name_get(self): self.assertEqual( - self.before_template_id.display_name, "Top template (Top)", + self.before_template_id.display_name, + "Top template (Top)", ) self.assertEqual( - self.after_template_id.display_name, "Bottom template (Bottom)", + self.after_template_id.display_name, + "Bottom template (Bottom)", ) def test_general_template(self):