Skip to content

Commit

Permalink
[IMP] cooperator: Migration script to populate company fields
Browse files Browse the repository at this point in the history
Signed-off-by: Carmen Bianca BAKKER <carmen@coopiteasy.be>
  • Loading branch information
carmenbianca committed Jun 7, 2023
1 parent 02ad6ec commit 9157219
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
2 changes: 1 addition & 1 deletion cooperator/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
18 changes: 18 additions & 0 deletions cooperator/migrations/14.0.1.7.0/post-migration.py
Original file line number Diff line number Diff line change
@@ -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)

0 comments on commit 9157219

Please sign in to comment.