From 9b738976fec9c9fbcdb8497769415c453ce60f39 Mon Sep 17 00:00:00 2001 From: "Pedro M. Baeza" Date: Thu, 12 Mar 2020 15:41:31 +0100 Subject: [PATCH] [FIX] base_comment_template: Make field truly company dependent Previous field declaration was incorrect due to a typo, leading to non applying the company dependent features. Now everything is correct and the migration scripts care of moving data properly. --- base_comment_template/__manifest__.py | 2 +- .../migrations/12.0.3.0.0/post-migration.py | 13 +++++++++++++ .../migrations/12.0.3.0.0/pre-migration.py | 13 +++++++++++++ base_comment_template/models/res_partner.py | 2 +- 4 files changed, 28 insertions(+), 2 deletions(-) create mode 100644 base_comment_template/migrations/12.0.3.0.0/post-migration.py create mode 100644 base_comment_template/migrations/12.0.3.0.0/pre-migration.py diff --git a/base_comment_template/__manifest__.py b/base_comment_template/__manifest__.py index 11c926f8..9dd125d0 100644 --- a/base_comment_template/__manifest__.py +++ b/base_comment_template/__manifest__.py @@ -4,7 +4,7 @@ { "name": "Base Comments Templates", "summary": "Comments templates on documents", - "version": "12.0.2.0.0", + "version": "12.0.3.0.0", "category": "Sale", "website": "https://github.com/OCA/account-invoice-reporting", "author": "Camptocamp, Odoo Community Association (OCA)", diff --git a/base_comment_template/migrations/12.0.3.0.0/post-migration.py b/base_comment_template/migrations/12.0.3.0.0/post-migration.py new file mode 100644 index 00000000..afb19530 --- /dev/null +++ b/base_comment_template/migrations/12.0.3.0.0/post-migration.py @@ -0,0 +1,13 @@ +# Copyright 2020 Tecnativa - Pedro M. Baeza +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). +from openupgradelib import openupgrade + + +@openupgrade.migrate() +def migrate(env, version): + table = 'res_partner' + old_column = 'property_comment_template_id' + new_column = openupgrade.get_legacy_name(old_column) + if openupgrade.column_exists(cr, table, new_column): + openupgrade.convert_to_company_dependent( + env, 'res.partner', old_column, new_column, 'res.partner') diff --git a/base_comment_template/migrations/12.0.3.0.0/pre-migration.py b/base_comment_template/migrations/12.0.3.0.0/pre-migration.py new file mode 100644 index 00000000..12b04d8c --- /dev/null +++ b/base_comment_template/migrations/12.0.3.0.0/pre-migration.py @@ -0,0 +1,13 @@ +# Copyright 2020 Tecnativa - Pedro M. Baeza +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). +from openupgradelib import openupgrade + + +@openupgrade.migrate() +def migrate(env, version): + cr = env.cr + table = 'res_partner' + old_column = 'property_comment_template_id' + new_column = openupgrade.get_legacy_name(old_column) + if openupgrade.column_exists(cr, table, old_column): + openupgrade.rename_columns(cr, {table: [(old_column, new_column)]}) diff --git a/base_comment_template/models/res_partner.py b/base_comment_template/models/res_partner.py index b7171210..c2d04609 100644 --- a/base_comment_template/models/res_partner.py +++ b/base_comment_template/models/res_partner.py @@ -9,7 +9,7 @@ class ResPartner(models.Model): property_comment_template_id = fields.Many2one( comodel_name='base.comment.template', string='Conditions template', - company_dependant=True, + company_dependent=True, ) @api.model