<commit_before>#    OpenERP, Open Source Management Solution
#    Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
#    Thinkopen - Brasil
#    Copyright (C) Thinkopen Solutions (<http://www.thinkopensolutions.com.br>)
#    Akretion
#    Copyright (C) Akretion (<http://www.akretion.com>)
# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html

from odoo import api, fields, models
from odoo.tools import config


class Company(models.Model):
    _name = "res.company"
    _inherit = [_name, "format.address.mixin", "l10n_br_base.party.mixin"]

    def _get_company_address_field_names(self):
        partner_fields = super()._get_company_address_field_names()
        return partner_fields + [
            "legal_name",
            "cnpj_cpf",
            "inscr_est",
            "inscr_mun",
            "district",
            "city_id",
            "suframa",
            "state_tax_number_ids",
            "street_number",
        ]

    def _inverse_legal_name(self):
        """Write the l10n_br specific functional fields."""
        for company in self:
            company.partner_id.legal_name = company.legal_name

    def _inverse_district(self):
        """Write the l10n_br specific functional fields."""
        for company in self:
            company.partner_id.district = company.district

    def _inverse_street_number(self):
        """Write the l10n_br specific functional fields."""
        for company in self:
            company.partner_id.street_number = company.street_number

    def _inverse_cnpj_cpf(self):
        """Write the l10n_br specific functional fields."""
        for company in self:
            company.partner_id.cnpj_cpf = company.cnpj_cpf

    def _inverse_state(self):
        """Write the l10n_br specific functional fields."""
        for company in self:
            company.partner_id.write(
                {"state_id": company.state_id.id, "inscr_est": company.inscr_est}
            )

    def _inverse_state_tax_number_ids(self):
        """Write the l10n_br specific functional fields."""
        for company in self:
            state_tax_number_ids = self.env["state.tax.numbers"]
            for ies in company.state_tax_number_ids:
                state_tax_number_ids |= ies
            company.partner_id.state_tax_number_ids = state_tax_number_ids

    def _inverse_inscr_mun(self):
        """Write the l10n_br specific functional fields."""
        for company in self:
            company.partner_id.inscr_mun = company.inscr_mun

    def _inverse_city_id(self):
        """Write the l10n_br specific functional fields."""
        for company in self:
            company.partner_id.city_id = company.city_id

    def _inverse_suframa(self):
        """Write the l10n_br specific functional fields."""
        for company in self:
            company.partner_id.suframa = company.suframa

    legal_name = fields.Char(
        compute="_compute_address",
        inverse="_inverse_legal_name",
    )

    district = fields.Char(
        compute="_compute_address",
        inverse="_inverse_district",
    )

    street_number = fields.Char(
        compute="_compute_address",
        inverse="_inverse_street_number",
    )

    city_id = fields.Many2one(
        domain="[('state_id', '=', state_id)]",<commit_msg>[ADD] street_name to res.company<commit_after>#    OpenERP, Open Source Management Solution
#    Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
#    Thinkopen - Brasil
#    Copyright (C) Thinkopen Solutions (<http://www.thinkopensolutions.com.br>)
#    Akretion
#    Copyright (C) Akretion (<http://www.akretion.com>)
# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html

from odoo import api, fields, models
from odoo.tools import config


class Company(models.Model):
    _name = "res.company"
    _inherit = [_name, "format.address.mixin", "l10n_br_base.party.mixin"]

    def _get_company_address_field_names(self):
        partner_fields = super()._get_company_address_field_names()
        return partner_fields + [
            "legal_name",
            "cnpj_cpf",
            "inscr_est",
            "inscr_mun",
            "district",
            "city_id",
            "suframa",
            "state_tax_number_ids",
            "street_number",
            "street_name",
        ]

    def _inverse_legal_name(self):
        """Write the l10n_br specific functional fields."""
        for company in self:
            company.partner_id.legal_name = company.legal_name

    def _inverse_district(self):
        """Write the l10n_br specific functional fields."""
        for company in self:
            company.partner_id.district = company.district

    def _inverse_street_name(self):
        """Write the l10n_br specific functional fields."""
        for company in self:
            company.partner_id.street_name = company.street_name

    def _inverse_street_number(self):
        """Write the l10n_br specific functional fields."""
        for company in self:
            company.partner_id.street_number = company.street_number

    def _inverse_cnpj_cpf(self):
        """Write the l10n_br specific functional fields."""
        for company in self:
            company.partner_id.cnpj_cpf = company.cnpj_cpf

    def _inverse_state(self):
        """Write the l10n_br specific functional fields."""
        for company in self:
            company.partner_id.write(
                {"state_id": company.state_id.id, "inscr_est": company.inscr_est}
            )

    def _inverse_state_tax_number_ids(self):
        """Write the l10n_br specific functional fields."""
        for company in self:
            state_tax_number_ids = self.env["state.tax.numbers"]
            for ies in company.state_tax_number_ids:
                state_tax_number_ids |= ies
            company.partner_id.state_tax_number_ids = state_tax_number_ids

    def _inverse_inscr_mun(self):
        """Write the l10n_br specific functional fields."""
        for company in self:
            company.partner_id.inscr_mun = company.inscr_mun

    def _inverse_city_id(self):
        """Write the l10n_br specific functional fields."""
        for company in self:
            company.partner_id.city_id = company.city_id

    def _inverse_suframa(self):
        """Write the l10n_br specific functional fields."""
        for company in self:
            company.partner_id.suframa = company.suframa

    legal_name = fields.Char(
        compute="_compute_address",
        inverse="_inverse_legal_name",
    )

    district = fields.Char(
        compute="_compute_address",
        inverse="_inverse_district",
    )

    street_name = fields.Char(
        compute="_compute_address",
        inverse="_inverse_street_name",
    )

    street_number = fields.Char(
        compute="_compute_address",
        inverse="_inverse_street_number",
    )

    city_id = fields.Many2one(
        domain="[('state_id', '=', state_id)]",
{'fraction_non_alphanumeric': 0.10079079798705967, 'fraction_numerical': 0.009489575844716032, 'mean_word_length': 2.4954773869346734, 'pattern_counts': {'":': 4, '<': 9, '<?xml version=': 0, '>': 9, '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': '228111', 'n_tokens_mistral': 2181, 'n_tokens_neox': 2043, 'n_words': 449}