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

import logging

from odoo import api, fields, models
from odoo.modules import get_module_resource

_logger = logging.getLogger(__name__)


class AddressAux(models.Model):

    _name = 'clv.address_aux'
    _description = 'Address (Aux)'
    _inherit = 'clv.abstract.partner_entity'

    code = fields.Char(string='Address (Aux) Code', required=False)

    notes = fields.Text(string='Notes:')

    @api.model
    def _create_vals(self, vals):
        vals = super()._create_vals(vals)
        vals.update({
            'customer': True,
        })
        vals.update({
            'type': self._name,
        })
        return vals

    @api.model_cr_context
    def _get_default_image_path(self, vals):
        res = super()._get_default_image_path(vals)
        if res:
            return res
        image_path = get_module_resource(
            'clv_address_aux', 'static/src/img', 'address_aux-avatar.png',
        )
        return image_path

    @api.multi
    def do_address_aux_clear_address_data(self):

        for address_aux in self:

            # _logger.info(u'>>>>> %s', address_aux.ref_address_id)

            # if (address_aux.reg_state in ['draft', 'revised']):

            data_values = {}

            data_values['street'] = False
            data_values['street2'] = False
            data_values['zip'] = False
            data_values['city'] = False
            data_values['state_id'] = False
            data_values['country_id'] = False
            # data_values['phone'] = False
            # data_values['mobile'] = False

            _logger.info(u'>>>>>>>>>> %s', data_values)

            address_aux.write(data_values)
<commit_msg>[IM clv_address_aux (ADD entity_code)<commit_after># -*- coding: utf-8 -*-
# Copyright (C) 2013-Today  <NAME> - CLVsol
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

import logging

from odoo import api, fields, models
from odoo.modules import get_module_resource

_logger = logging.getLogger(__name__)


class AddressAux(models.Model):

    _name = 'clv.address_aux'
    _description = 'Address (Aux)'
    _inherit = 'clv.abstract.partner_entity'

    code = fields.Char(string='Address (Aux) Code', required=False)

    notes = fields.Text(string='Notes:')

    @api.model
    def _create_vals(self, vals):
        vals = super()._create_vals(vals)
        vals.update({
            'customer': True,
        })
        vals.update({
            'type': self._name,
        })
        return vals

    @api.model_cr_context
    def _get_default_image_path(self, vals):
        res = super()._get_default_image_path(vals)
        if res:
            return res
        image_path = get_module_resource(
            'clv_address_aux', 'static/src/img', 'address_aux-avatar.png',
        )
        return image_path

    @api.multi
    def write(self, values):
        ret = super().write(values)
        for record in self:
            if ('code' in values):
                if record.entity_code != values['code']:
                    vals = {}
                    vals['entity_code'] = values['code']
                    super().write(vals)
        return ret

    @api.multi
    def do_address_aux_clear_address_data(self):

        for address_aux in self:

            # _logger.info(u'>>>>> %s', address_aux.ref_address_id)

            # if (address_aux.reg_state in ['draft', 'revised']):

            data_values = {}

            data_values['street'] = False
            data_values['street2'] = False
            data_values['zip'] = False
            data_values['city'] = False
            data_values['state_id'] = False
            data_values['country_id'] = False
            # data_values['phone'] = False
            # data_values['mobile'] = False

            _logger.info(u'>>>>>>>>>> %s', data_values)

            address_aux.write(data_values)

{'fraction_non_alphanumeric': 0.1278401997503121, 'fraction_numerical': 0.003995006242197253, 'mean_word_length': 2.2125100240577384, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 35, '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': '6596947', 'n_tokens_mistral': 1280, 'n_tokens_neox': 1216, 'n_words': 246}