<commit_before>##############################################################################
#
#    Copyright (C) 2018 Compassion CH (http://www.compassion.ch)
#    @author: <NAME> <<EMAIL>>
#
#    The licence is in the file __manifest__.py
#
##############################################################################
from openupgradelib import openupgrade

from odoo.addons.child_compassion import load_mappings


@openupgrade.migrate(use_env=True)
def migrate(env, version):
    if not version:
        return

    load_mappings(env.cr, env)<commit_msg>Add migration for assigning security groups<commit_after>##############################################################################
#
#    Copyright (C) 2018 Compassion CH (http://www.compassion.ch)
#    @author: <NAME> <<EMAIL>>
#
#    The licence is in the file __manifest__.py
#
##############################################################################
from openupgradelib import openupgrade

from odoo.addons.child_compassion import load_mappings


@openupgrade.migrate(use_env=True)
def migrate(env, version):
    if not version:
        return

    load_mappings(env.cr, env)

    # Add sponsorship group to everyone
    sponsorship_group = env.ref('child_compassion.group_sponsorship')
    env['res.users'].search([
        ('internal', '=', True),
        ('email', 'ilike', 'compassion.ch')
    ]).write({
        'groups_id': [(4, sponsorship_group.id)]
    })
    # Add admin groups
    sponsorship_manager_group = env.ref('child_compassion.group_manager')
    gmc_manager_group = env.ref('message_center_compassion.group_gmc_manager')
    env['res.users'].search([
        ('login', 'in', ['ecino', 'dwulliamoz', 'seicher', 'admin']),
    ]).write({
        'groups_id': [(4, sponsorship_manager_group.id), (4, gmc_manager_group.id)]
    })
{'fraction_non_alphanumeric': 0.28390993959362987, 'fraction_numerical': 0.0060406370126304225, 'mean_word_length': 4.877419354838709, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5933007', 'n_tokens_mistral': 557, 'n_tokens_neox': 513, 'n_words': 111}