<commit_before># -*- coding: utf-8 -*-
# © 2016-2017 Akretion (http://www.akretion.com)
# © 2016-2017 Camptocamp (http://www.camptocamp.com/)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).

from odoo import api, models


def get_new_values(model, record, on_change_result):
    vals = on_change_result.get('value', {})
    new_values = {}
    for fieldname, value in vals.iteritems():
        if fieldname not in record:
            column = model._fields[fieldname]
            if column.type == 'many2one':
                value = value[0]  # many2one are tuple (id, name)
            new_values[fieldname] = value
    return new_values


@api.model
def play_onchanges(self, values, onchange_fields):
    onchange_specs = self._onchange_spec()<commit_msg>[FIX] avoid a crash when value is False for a M2O field<commit_after># -*- coding: utf-8 -*-
# © 2016-2017 Akretion (http://www.akretion.com)
# © 2016-2017 Camptocamp (http://www.camptocamp.com/)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).

from odoo import api, models


def get_new_values(model, record, on_change_result):
    vals = on_change_result.get('value', {})
    new_values = {}
    for fieldname, value in vals.iteritems():
        if fieldname not in record:
            column = model._fields[fieldname]
            if value and column.type == 'many2one':
                value = value[0]  # many2one are tuple (id, name)
            new_values[fieldname] = value
    return new_values


@api.model
def play_onchanges(self, values, onchange_fields):
    onchange_specs = self._onchange_spec()
{'fraction_non_alphanumeric': 0.12795031055900621, 'fraction_numerical': 0.027950310559006212, 'mean_word_length': 3.0275, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 6, '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': '6698629', 'n_tokens_mistral': 566, 'n_tokens_neox': 526, 'n_words': 134}