Odoo Mindscape. Understand Odoo faster. Explore modules, fields, dependencies and version differences in one place instead of digging through the source code.

Module: Peru - Accounting

Entity: res.partner

Compute Method: _compute_l10n_pe_sunat_identification

Inputs Method Outputs
""" The identification the partner is invoiced with, its preferred identifier paired
        with the SUNAT code (catálogo 06) describing which document it is. """
for partner in self:
            vals = partner._get_preferred_legal_entity_identifier_vals()
            if not (sunat_code := PE_SUNAT_CODES.get(vals.get('key'))):
                if 'PE' in (vals.get('countries') or []) and vals.get('category') in TIN_CATEGORIES:
                    sunat_code = PE_RUC_SUNAT_CODE
                elif vals and vals.get('category') not in TIN_CATEGORIES:
                    sunat_code = PE_FOREIGN_ID_SUNAT_CODE
                else:
                    sunat_code = PE_FOREIGN_VAT_SUNAT_CODE
            partner.l10n_pe_sunat_id_code = sunat_code
            partner.l10n_pe_sunat_id_value = vals.get('value')

Back to entity