diff --git a/base_comment_template/migrations/12.0.2.0.0/post-migrate.py b/base_comment_template/migrations/12.0.2.0.0/post-migrate.py deleted file mode 100644 index e08ccabb..00000000 --- a/base_comment_template/migrations/12.0.2.0.0/post-migrate.py +++ /dev/null @@ -1,57 +0,0 @@ -from odoo import tools - -import logging -_logger = logging.getLogger(__name__) - - -def migrate(cr, version): - - _logger.debug('Migrating res.partner comment_template_id') - - if not tools.column_exists(cr, 'res_partner', 'comment_template_id'): - return - - cr.execute("SELECT id FROM res_company") - company_ids = [d[0] for d in cr.fetchall()] - - cr.execute( - "SELECT id FROM ir_model_fields WHERE model=%s AND name=%s", - ('res.partner', 'property_comment_template_id')) - [field_id] = cr.fetchone() - - for company_id in company_ids: - cr.execute(""" - INSERT INTO ir_property( - name, - type, - fields_id, - company_id, - res_id, - value_reference - ) - SELECT - {field}, - 'many2one', - {field_id}, - {company_id}, - CONCAT('{model},',id), - CONCAT('{target_model},',{oldfield}) - FROM {table} t - WHERE {oldfield} IS NOT NULL - AND (company_id IS NULL OR company_id = {company_id}) - AND NOT EXISTS( - SELECT 1 - FROM ir_property - WHERE fields_id={field_id} - AND company_id={company_id} - AND res_id=CONCAT('{model},',t.id) - ) - """.format( - oldfield='comment_template_id', - field='property_comment_template_id', - field_id=field_id, - company_id=company_id, - model='res.partner', - target_model='base.comment.template', - table='res_partner', - )) 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 deleted file mode 100644 index afb19530..00000000 --- a/base_comment_template/migrations/12.0.3.0.0/post-migration.py +++ /dev/null @@ -1,13 +0,0 @@ -# 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 deleted file mode 100644 index 12b04d8c..00000000 --- a/base_comment_template/migrations/12.0.3.0.0/pre-migration.py +++ /dev/null @@ -1,13 +0,0 @@ -# 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)]})