From 9157219e2dbe46de03f6805a09bffcd5c8116991 Mon Sep 17 00:00:00 2001 From: Carmen Bianca BAKKER Date: Wed, 7 Jun 2023 10:47:01 +0200 Subject: [PATCH] [IMP] cooperator: Migration script to populate company fields Signed-off-by: Carmen Bianca BAKKER --- cooperator/__manifest__.py | 2 +- .../migrations/14.0.1.7.0/post-migration.py | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) create mode 100644 cooperator/migrations/14.0.1.7.0/post-migration.py diff --git a/cooperator/__manifest__.py b/cooperator/__manifest__.py index 647cba1e9..e56709f5c 100644 --- a/cooperator/__manifest__.py +++ b/cooperator/__manifest__.py @@ -7,7 +7,7 @@ { "name": "Cooperators", "summary": "Manage your cooperators", - "version": "14.0.1.6.0", + "version": "14.0.1.7.0", "depends": [ "base", "web", diff --git a/cooperator/migrations/14.0.1.7.0/post-migration.py b/cooperator/migrations/14.0.1.7.0/post-migration.py new file mode 100644 index 000000000..30e23f9a5 --- /dev/null +++ b/cooperator/migrations/14.0.1.7.0/post-migration.py @@ -0,0 +1,18 @@ +# SPDX-FileCopyrightText: 2023 Coop IT Easy SC +# +# SPDX-License-Identifier: AGPL-3.0-or-later + +import logging + +from odoo import SUPERUSER_ID, api + +_logger = logging.getLogger(__name__) + + +def migrate(cr, version): + env = api.Environment(cr, SUPERUSER_ID, {}) + mail_template_fields = env["res.company"]._get_cooperator_mail_template_fields() + for field, xmlid in mail_template_fields.items(): + company_ids = env["res.company"].search([(field, "=", False)]) + _logger.info("populating field %s on companies %s", field, company_ids) + company_ids._assign_default_cooperator_mail_template(field, xmlid)