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,9 @@
# coding: utf-8
# Copyright 2016 Vauxoo (https://www.vauxoo.com) <info@vauxoo.com>
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl).
from . import account_account
from . import account_tax
from . import res_bank
from . import res_config_settings
from . import chart_template

View file

@ -0,0 +1,19 @@
from odoo import api, Command, models
class AccountAccount(models.Model):
_inherit = 'account.account'
@api.model_create_multi
def create(self, vals_list):
# EXTENDS account - ensure there is a tag on created MX accounts
# The computation is a bit naive and might not be correct in all cases.
accounts = super().create(vals_list)
debit_tag = self.env.ref('l10n_mx.tag_debit_balance_account')
credit_tag = self.env.ref('l10n_mx.tag_credit_balance_account')
mx_account_no_tags = accounts.filtered(lambda a: a.company_id.country_code == 'MX' and not a.tag_ids & (credit_tag + debit_tag))
DEBIT_CODES = ['1', '5', '6', '7'] # all other codes are considered "credit"
for account in mx_account_no_tags:
tag_id = debit_tag.id if account.code[0] in DEBIT_CODES else credit_tag.id
account.tag_ids = [Command.link(tag_id)]
return accounts

View file

@ -0,0 +1,38 @@
# coding: utf-8
from odoo import models, fields
class AccountTaxTemplate(models.Model):
_inherit = 'account.tax.template'
l10n_mx_tax_type = fields.Selection(
selection=[
('Tasa', "Tasa"),
('Cuota', "Cuota"),
('Exento', "Exento"),
],
string="Factor Type",
default='Tasa',
help="The CFDI version 3.3 have the attribute 'TipoFactor' in the tax lines. In it is indicated the factor "
"type that is applied to the base of the tax.")
def _get_tax_vals(self, company, tax_template_to_tax):
# OVERRIDE
res = super()._get_tax_vals(company, tax_template_to_tax)
res['l10n_mx_tax_type'] = self.l10n_mx_tax_type
return res
class AccountTax(models.Model):
_inherit = 'account.tax'
l10n_mx_tax_type = fields.Selection(
selection=[
('Tasa', "Tasa"),
('Cuota', "Cuota"),
('Exento', "Exento"),
],
string="Factor Type",
default='Tasa',
help="The CFDI version 3.3 have the attribute 'TipoFactor' in the tax lines. In it is indicated the factor "
"type that is applied to the base of the tax.")

View file

@ -0,0 +1,49 @@
# coding: utf-8
# Copyright 2016 Vauxoo (https://www.vauxoo.com) <info@vauxoo.com>
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl).
from odoo import models, api, _
class AccountChartTemplate(models.Model):
_inherit = "account.chart.template"
def _load(self, company):
res = super()._load(company)
if company.chart_template_id == self.env.ref('l10n_mx.mx_coa'):
company.write({
'account_sale_tax_id': self.env.ref(f'l10n_mx.{company.id}_tax12'),
'account_purchase_tax_id': self.env.ref(f'l10n_mx.{company.id}_tax14'),
})
return res
@api.model
def generate_journals(self, acc_template_ref, company, journals_dict=None):
"""Set the tax_cash_basis_journal_id on the company"""
res = super(AccountChartTemplate, self).generate_journals(
acc_template_ref, company, journals_dict=journals_dict)
if not self == self.env.ref('l10n_mx.mx_coa'):
return res
journal_basis = self.env['account.journal'].search([
('company_id', '=', company.id),
('type', '=', 'general'),
('code', '=', 'CBMX')], limit=1)
company.write({'tax_cash_basis_journal_id': journal_basis.id})
return res
def _prepare_all_journals(self, acc_template_ref, company, journals_dict=None):
"""Create the tax_cash_basis_journal_id"""
res = super(AccountChartTemplate, self)._prepare_all_journals(
acc_template_ref, company, journals_dict=journals_dict)
if not self == self.env.ref('l10n_mx.mx_coa'):
return res
account = acc_template_ref.get(self.env.ref('l10n_mx.cuenta118_01').id)
res.append({
'type': 'general',
'name': _('Effectively Paid'),
'code': 'CBMX',
'company_id': company.id,
'default_account_id': account,
'show_on_dashboard': True,
})
return res

View file

@ -0,0 +1,21 @@
# coding: utf-8
# Part of Odoo. See LICENSE file for full copyright and licensing details.
from odoo import fields, models
class Bank(models.Model):
_inherit = "res.bank"
l10n_mx_edi_code = fields.Char(
"ABM Code",
help="Three-digit number assigned by the ABM to identify banking "
"institutions (ABM is an acronym for Asociación de Bancos de México)")
class ResPartnerBank(models.Model):
_inherit = "res.partner.bank"
l10n_mx_edi_clabe = fields.Char(
"CLABE", help="Standardized banking cipher for Mexico. More info "
"wikipedia.org/wiki/CLABE")

View file

@ -0,0 +1,9 @@
# -*- coding: utf-8 -*-
from odoo import fields, models
class ResConfigSettings(models.TransientModel):
_inherit = 'res.config.settings'
module_l10n_mx_edi = fields.Boolean('Mexican Electronic Invoicing')