Browse Source

[IMP] base_comment_template: Adapt to 14.0

myc-14.0-py3o
Víctor Martínez 4 years ago
parent
commit
85f9bc918e
  1. 12
      base_comment_template/README.rst
  2. 4
      base_comment_template/__manifest__.py
  3. 25
      base_comment_template/migrations/13.0.1.0.0/pre-migration.py
  4. 12
      base_comment_template/migrations/13.0.2.0.0/pre-migration.py
  5. 21
      base_comment_template/migrations/13.0.3.0.0/pre-migration.py
  6. 26
      base_comment_template/migrations/14.0.1.0.0/pre-migration.py
  7. 29
      base_comment_template/migrations/14.0.2.0.0/post-migration.py
  8. 30
      base_comment_template/migrations/14.0.2.0.0/pre-migration.py
  9. 3
      base_comment_template/models/base_comment_template.py
  10. 8
      base_comment_template/static/description/index.html
  11. 9
      base_comment_template/tests/test_base_comment_template.py

12
base_comment_template/README.rst

@ -14,13 +14,13 @@ Base Comments Templates
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
:alt: License: AGPL-3 :alt: License: AGPL-3
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Freporting--engine-lightgray.png?logo=github .. |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 :alt: OCA/reporting-engine
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png .. |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 :alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png .. |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 :alt: Try me on Runbot
|badge1| |badge2| |badge3| |badge4| |badge5| |badge1| |badge2| |badge3| |badge4| |badge5|
@ -107,7 +107,7 @@ Bug Tracker
Bugs are tracked on `GitHub Issues <https://github.com/OCA/reporting-engine/issues>`_. 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. 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 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:%2013.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:%2014.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. Do not contact contributors directly about support or help with technical issues.
@ -134,6 +134,7 @@ Contributors
* `Druidoo <https://www.druidoo.io>`_: * `Druidoo <https://www.druidoo.io>`_:
* Iván Todorovich <ivan.todorovich@druidoo.io> * Iván Todorovich <ivan.todorovich@druidoo.io>
* Pierre Verkest <pierreverkest84@gmail.com>
* `NextERP Romania <https://www.nexterp.ro>`_: * `NextERP Romania <https://www.nexterp.ro>`_:
@ -142,6 +143,7 @@ Contributors
* `Tecnativa <https://www.tecnativa.com>`_: * `Tecnativa <https://www.tecnativa.com>`_:
* Carlos Roca * Carlos Roca
* Víctor Martínez
Maintainers 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 mission is to support the collaborative development of Odoo features and
promote its widespread use. promote its widespread use.
This module is part of the `OCA/reporting-engine <https://github.com/OCA/reporting-engine/tree/13.0/base_comment_template>`_ project on GitHub.
This module is part of the `OCA/reporting-engine <https://github.com/OCA/reporting-engine/tree/14.0/base_comment_template>`_ project on GitHub.
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

4
base_comment_template/__manifest__.py

@ -3,9 +3,9 @@
{ {
"name": "Base Comments Templates", "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.", "on models that inherits comment.template.",
"version": "14.0.1.0.0",
"version": "14.0.2.0.0",
"category": "Reporting", "category": "Reporting",
"website": "https://github.com/OCA/reporting-engine", "website": "https://github.com/OCA/reporting-engine",
"author": "Camptocamp, Odoo Community Association (OCA)", "author": "Camptocamp, Odoo Community Association (OCA)",

25
base_comment_template/migrations/13.0.1.0.0/pre-migration.py

@ -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'
""",
)

12
base_comment_template/migrations/13.0.2.0.0/pre-migration.py

@ -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)

21
base_comment_template/migrations/13.0.3.0.0/pre-migration.py

@ -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"
)

26
base_comment_template/migrations/14.0.1.0.0/pre-migration.py

@ -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)

29
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
""",
)

30
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"
)

3
base_comment_template/models/base_comment_template.py

@ -76,8 +76,7 @@ class BaseCommentTemplate(models.Model):
) )
def name_get(self): 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 = [] res = []
for item in self: for item in self:
name = "{} ({})".format( name = "{} ({})".format(

8
base_comment_template/static/description/index.html

@ -367,7 +367,7 @@ ul.auto-toc {
!! This file is generated by oca-gen-addon-readme !! !! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !! !! 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/13.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-13-0/reporting-engine-13-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/13.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/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>Add a new mixin class to define templates of comments to print on documents. <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> 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> <p>Two positions are available for the comments:</p>
@ -448,7 +448,7 @@ If you create a new template with the same configuration (Model, Domain, Positio
<p>Bugs are tracked on <a class="reference external" href="https://github.com/OCA/reporting-engine/issues">GitHub Issues</a>. <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. 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 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:%2013.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:%2014.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> <p>Do not contact contributors directly about support or help with technical issues.</p>
</div> </div>
<div class="section" id="credits"> <div class="section" id="credits">
@ -475,12 +475,14 @@ If you spotted it first, help us smashing it by providing a detailed and welcome
<li>Iván Todorovich &lt;<a class="reference external" href="mailto:ivan.todorovich&#64;druidoo.io">ivan.todorovich&#64;druidoo.io</a>&gt;</li> <li>Iván Todorovich &lt;<a class="reference external" href="mailto:ivan.todorovich&#64;druidoo.io">ivan.todorovich&#64;druidoo.io</a>&gt;</li>
</ul> </ul>
</li> </li>
<li>Pierre Verkest &lt;<a class="reference external" href="mailto:pierreverkest84&#64;gmail.com">pierreverkest84&#64;gmail.com</a>&gt;</li>
<li><a class="reference external" href="https://www.nexterp.ro">NextERP Romania</a>:<ul> <li><a class="reference external" href="https://www.nexterp.ro">NextERP Romania</a>:<ul>
<li>Fekete Mihai &lt;<a class="reference external" href="mailto:feketemihai&#64;nexterp.ro">feketemihai&#64;nexterp.ro</a>&gt;</li> <li>Fekete Mihai &lt;<a class="reference external" href="mailto:feketemihai&#64;nexterp.ro">feketemihai&#64;nexterp.ro</a>&gt;</li>
</ul> </ul>
</li> </li>
<li><a class="reference external" href="https://www.tecnativa.com">Tecnativa</a>:<ul> <li><a class="reference external" href="https://www.tecnativa.com">Tecnativa</a>:<ul>
<li>Carlos Roca</li> <li>Carlos Roca</li>
<li>Víctor Martínez</li>
</ul> </ul>
</li> </li>
</ul> </ul>
@ -492,7 +494,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 <p>OCA, or the Odoo Community Association, is a nonprofit organization whose
mission is to support the collaborative development of Odoo features and mission is to support the collaborative development of Odoo features and
promote its widespread use.</p> promote its widespread use.</p>
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/reporting-engine/tree/13.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/14.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> <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>
</div> </div>

9
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): class TestCommentTemplate(common.SavepointCase):
at_install = False
post_install = True
@classmethod @classmethod
def setUpClass(cls): def setUpClass(cls):
super().setUpClass() super().setUpClass()
@ -50,10 +47,12 @@ class TestCommentTemplate(common.SavepointCase):
def test_template_name_get(self): def test_template_name_get(self):
self.assertEqual( self.assertEqual(
self.before_template_id.display_name, "Top template (Top)",
self.before_template_id.display_name,
"Top template (Top)",
) )
self.assertEqual( 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): def test_general_template(self):

Loading…
Cancel
Save