Initial commit: L10N_Americas packages

This commit is contained in:
Ernad Husremovic 2025-08-29 15:20:52 +02:00
commit 12b27ce151
714 changed files with 79328 additions and 0 deletions

View file

@ -0,0 +1,11 @@
# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.
# Copyright (C) 2009 Renato Lima - Akretion
from . import account
from . import account_fiscal_position_template
from . import account_fiscal_position
from . import account_chart_template
from . import res_company
from . import res_partner

View file

@ -0,0 +1,28 @@
# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.
from odoo import fields, models
class AccountTaxTemplate(models.Model):
""" Add fields used to define some brazilian taxes """
_inherit = 'account.tax.template'
tax_discount = fields.Boolean(string='Discount this Tax in Prince',
help="Mark it for (ICMS, PIS e etc.).")
base_reduction = fields.Float(string='Redution', digits=0, required=True,
help="Um percentual decimal em % entre 0-1.", default=0)
amount_mva = fields.Float(string='MVA Percent', digits=0, required=True,
help="Um percentual decimal em % entre 0-1.", default=0)
class AccountTax(models.Model):
""" Add fields used to define some brazilian taxes """
_inherit = 'account.tax'
tax_discount = fields.Boolean(string='Discount this Tax in Prince',
help="Mark it for (ICMS, PIS e etc.).")
base_reduction = fields.Float(string='Redution', digits=0, required=True,
help="Um percentual decimal em % entre 0-1.", default=0)
amount_mva = fields.Float(string='MVA Percent', digits=0, required=True,
help="Um percentual decimal em % entre 0-1.", default=0)

View file

@ -0,0 +1,13 @@
# Part of Odoo. See LICENSE file for full copyright and licensing details.
from odoo import models
class AccountChartTemplate(models.Model):
_inherit = 'account.chart.template'
def _get_fp_vals(self, company, position):
res = super()._get_fp_vals(company, position)
if company.country_id.code == 'BR':
res['l10n_br_fp_type'] = position['l10n_br_fp_type']
return res

View file

@ -0,0 +1,42 @@
# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.
from odoo import api, fields, models
SOUTH_SOUTHEAST = {"PR", "RS", "SC", "SP", "ES", "MG", "RJ"}
NORTH_NORTHEAST_MIDWEST = {
"AC", "AP", "AM", "PA", "RO", "RR", "TO", "AL", "BA", "CE",
"MA", "PB", "PE", "PI", "RN", "SE", "DF", "GO", "MT", "MS"
}
class AccountFiscalPosition(models.Model):
_inherit = 'account.fiscal.position'
l10n_br_fp_type = fields.Selection(
selection=[
('internal', 'Internal'),
('ss_nnm', 'South/Southeast selling to North/Northeast/Midwest'),
('interstate', 'Other interstate'),
],
string='Interstate Fiscal Position Type',
)
@api.model
def _get_fiscal_position(self, partner, delivery=None):
if not delivery:
delivery = partner
if self.env.company.country_id.code != "BR" or delivery.country_id.code != 'BR':
return super()._get_fiscal_position(partner, delivery=delivery)
# manually set fiscal position on partner has a higher priority
manual_fiscal_position = delivery.property_account_position_id or partner.property_account_position_id
if manual_fiscal_position:
return manual_fiscal_position
# Taxation in Brazil depends on both the state of the partner and the state of the company
if self.env.company.state_id == delivery.state_id:
return self.search([('l10n_br_fp_type', '=', 'internal'), ('company_id', '=', self.env.company.id)], limit=1)
if self.env.company.state_id.code in SOUTH_SOUTHEAST and delivery.state_id.code in NORTH_NORTHEAST_MIDWEST:
return self.search([('l10n_br_fp_type', '=', 'ss_nnm'), ('company_id', '=', self.env.company.id)], limit=1)
return self.search([('l10n_br_fp_type', '=', 'interstate'), ('company_id', '=', self.env.company.id)], limit=1)

View file

@ -0,0 +1,16 @@
# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.
from odoo import fields, models
class AccountFiscalPositionTemplate(models.Model):
_inherit = 'account.fiscal.position.template'
l10n_br_fp_type = fields.Selection(
selection=[
('internal', 'Internal'),
('ss_nnm', 'South/Southeast selling to North/Northeast/Midwest'),
('interstate', 'Other interstate'),
],
string='Interstate Fiscal Position Type',
)

View file

@ -0,0 +1,14 @@
# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.
from odoo import fields, models
class ResCompany(models.Model):
_inherit = "res.company"
# ==== Business fields ====
l10n_br_cpf_code = fields.Char(string="CPF", help="Natural Persons Register.")
l10n_br_ie_code = fields.Char(string="IE", help="State Tax Identification Number. Should contain 9-14 digits.") # each state has its own format. Not all of the validation rules can be easily found.
l10n_br_im_code = fields.Char(string="IM", help="Municipal Tax Identification Number") # each municipality has its own format. There is no information about validation anywhere.
l10n_br_nire_code = fields.Char(string="NIRE", help="State Commercial Identification Number. Should contain 11 digits.")

View file

@ -0,0 +1,15 @@
# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.
from odoo import _, api, fields, models
from odoo.exceptions import ValidationError
import re
class ResPartner(models.Model):
_inherit = 'res.partner'
l10n_br_cpf_code = fields.Char(string="CPF", help="Natural Persons Register.")
l10n_br_ie_code = fields.Char(string="IE", help="State Tax Identification Number. Should contain 9-14 digits.")
l10n_br_im_code = fields.Char(string="IM", help="Municipal Tax Identification Number")
l10n_br_isuf_code = fields.Char(string="SUFRAMA code", help="SUFRAMA registration number.")