<commit_before># -*- coding: utf-8 -*-
# Copyright (C) 2013-Today  <NAME> - CLVsol
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from openerp import api, fields, models


class Family(models.Model):
    _inherit = 'clv.family'

    suggested_name = fields.Char(
        string="Suggested Name", required=False, store=True,
        compute="_get_suggested_name",
        help='Suggested Name for the Family.'
    )
    automatic_set_name = fields.Boolean(
        string='Automatic Name',
        help="If checked, the Family Name will be set automatically.",
        default=True
    )

    @api.depends('street', 'street2')
    def _get_suggested_name(self):
        for record in self:
            if record.street:
                record.suggested_name = record.street
                if record.street2:
                    record.suggested_name = record.suggested_name + ' - ' + record.street2
            # else:
            #     if not record.suggested_name:
            #         if record.code:
            #             record.suggested_name = record.code

    @api.multi
    def write(self, values):
        ret = super(Family, self).write(values)
        for record in self:
            if record.automatic_set_name:
                if record.name != record.suggested_name:
                    values['name'] = record.suggested_name
                    super(Family, record).write(values)
            else:
                if ('name' in values and values['name'] == '/') or \
                   (record.name == '/'):
                    values['name'] = record.suggested_name
                    super(Family, record).write(values)
        return ret<commit_msg>[IMP] clv_family (IMP models/family_name.py)<commit_after># -*- coding: utf-8 -*-
# Copyright (C) 2013-Today  <NAME> - CLVsol
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from openerp import api, fields, models


class Family(models.Model):
    _inherit = 'clv.family'

    suggested_name = fields.Char(
        string="Suggested Name", required=False, store=True,
        compute="_get_suggested_name",
        help='Suggested Name for the Family.'
    )
    automatic_set_name = fields.Boolean(
        string='Automatic Name',
        help="If checked, the Family Name will be set automatically.",
        default=True
    )

    @api.depends('street', 'street2')
    def _get_suggested_name(self):
        for record in self:
            if record.street:
                record.suggested_name = record.street
                if record.street2:
                    record.suggested_name = record.suggested_name + ' - ' + record.street2
            # else:
            #     if not record.suggested_name:
            #         if record.code:
            #             record.suggested_name = record.code

    @api.multi
    def write(self, values):
        ret = super(Family, self).write(values)
        for record in self:
            if record.suggested_name is not False:
                if record.automatic_set_name:
                    if record.name != record.suggested_name:
                        values['name'] = record.suggested_name
                        super(Family, record).write(values)
                else:
                    if ('name' in values and values['name'] == '/') or \
                       (record.name == '/'):
                        values['name'] = record.suggested_name
                        super(Family, record).write(values)
        return ret
{'fraction_non_alphanumeric': 0.10901826484018265, 'fraction_numerical': 0.005707762557077625, 'mean_word_length': 1.777337559429477, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '5809218', 'n_tokens_mistral': 1021, 'n_tokens_neox': 939, 'n_words': 225}