mirror of
https://github.com/bringout/oca-ocb-l10n_americas.git
synced 2026-04-26 16:32:07 +02:00
Initial commit: L10N_Americas packages
This commit is contained in:
commit
12b27ce151
714 changed files with 79328 additions and 0 deletions
|
|
@ -0,0 +1,73 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
|
||||
from odoo import api, SUPERUSER_ID
|
||||
|
||||
def update_withhold_type(env):
|
||||
# reclassifies withhold taxes into independent tax groups for sales and purchases
|
||||
env.cr.execute('''
|
||||
UPDATE account_tax
|
||||
SET tax_group_id=t.id FROM (SELECT id FROM account_tax_group WHERE l10n_ec_type='withhold_vat_sale') AS t
|
||||
WHERE account_tax.id IN (SELECT id FROM account_tax WHERE tax_group_id IN (SELECT id FROM account_tax_group WHERE l10n_ec_type='withhold_vat') AND type_tax_use='sale')
|
||||
''')
|
||||
env.cr.execute('''
|
||||
UPDATE account_tax
|
||||
SET tax_group_id=t.id FROM (SELECT id FROM account_tax_group WHERE l10n_ec_type='withhold_vat_purchase') AS t
|
||||
WHERE account_tax.id IN (SELECT id FROM account_tax WHERE tax_group_id IN (SELECT id FROM account_tax_group WHERE l10n_ec_type='withhold_vat') AND type_tax_use='purchase')
|
||||
''')
|
||||
env.cr.execute('''
|
||||
UPDATE account_tax
|
||||
SET tax_group_id=t.id FROM (SELECT id FROM account_tax_group WHERE l10n_ec_type='withhold_income_sale') AS t
|
||||
WHERE account_tax.id IN (SELECT id FROM account_tax WHERE tax_group_id IN (SELECT id FROM account_tax_group WHERE l10n_ec_type='withhold_income_tax') AND type_tax_use='sale')
|
||||
''')
|
||||
env.cr.execute('''
|
||||
UPDATE account_tax
|
||||
SET tax_group_id=t.id FROM (SELECT id FROM account_tax_group WHERE l10n_ec_type='withhold_income_purchase') AS t
|
||||
WHERE account_tax.id IN (SELECT id FROM account_tax WHERE tax_group_id IN (SELECT id FROM account_tax_group WHERE l10n_ec_type='withhold_income_tax') AND type_tax_use='purchase')
|
||||
''')
|
||||
|
||||
def update_type_tax_use(env):
|
||||
# sets type_tax_use = none for withholding taxes
|
||||
env.cr.execute('''
|
||||
UPDATE account_tax
|
||||
SET type_tax_use = 'none'
|
||||
WHERE tax_group_id IN (SELECT id FROM account_tax_group WHERE l10n_ec_type IN ('withhold_income_purchase','withhold_vat_purchase','withhold_income_sale','withhold_vat_sale'))
|
||||
''')
|
||||
|
||||
def update_tax_repartition_line_vat_withhold(env):
|
||||
# For tax repartition lines in vat withhold taxes, replace factor_percent=12% with factor_percent=100%
|
||||
env.cr.execute('''
|
||||
--for invoice_tax_id
|
||||
UPDATE account_tax_repartition_line
|
||||
SET factor_percent = 100
|
||||
WHERE factor_percent = 12
|
||||
AND repartition_type = 'tax'
|
||||
AND invoice_tax_id in (
|
||||
SELECT id
|
||||
FROM account_tax
|
||||
WHERE country_id = (SELECT id FROM res_country WHERE code = 'EC' LIMIT 1) --Country is Ecuador)
|
||||
AND tax_group_id IN (
|
||||
SELECT id FROM account_tax_group WHERE l10n_ec_type IN ('withhold_vat_sale', 'withhold_vat_purchase')
|
||||
)
|
||||
)
|
||||
''')
|
||||
env.cr.execute('''
|
||||
--for refund_tax_id
|
||||
UPDATE account_tax_repartition_line
|
||||
SET factor_percent = 100
|
||||
WHERE factor_percent = 12
|
||||
AND repartition_type = 'tax'
|
||||
AND refund_tax_id in (
|
||||
SELECT id
|
||||
FROM account_tax
|
||||
WHERE country_id = (SELECT id FROM res_country WHERE code = 'EC' LIMIT 1) --Country is Ecuador)
|
||||
AND tax_group_id IN (
|
||||
SELECT id FROM account_tax_group WHERE l10n_ec_type IN ('withhold_vat_sale','withhold_vat_purchase')
|
||||
)
|
||||
)
|
||||
''')
|
||||
|
||||
def migrate(cr, version):
|
||||
env = api.Environment(cr, SUPERUSER_ID, {})
|
||||
update_withhold_type(env)
|
||||
update_type_tax_use(env)
|
||||
update_tax_repartition_line_vat_withhold(env)
|
||||
|
|
@ -0,0 +1,69 @@
|
|||
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
||||
|
||||
from odoo.addons.account.models.chart_template import update_taxes_from_templates
|
||||
from odoo import api, SUPERUSER_ID
|
||||
|
||||
def update_names(cr, env):
|
||||
"""
|
||||
Update the names in the taxes
|
||||
"""
|
||||
companies = env['res.company'].search([('chart_template_id', '=', env.ref('l10n_ec.l10n_ec_ifrs').id)])
|
||||
for company in companies:
|
||||
taxes_to_update = [
|
||||
(f'{company.id}_tax_withhold_profit_312A', '312A 1% Compras al Productor: de Bienes de Origen Bioacuático, Forestal y los Descritos el Art.27.1 de LRTI'),
|
||||
(f'{company.id}_tax_withhold_profit_308', '308 10% Utilizacion o Aprovechamiento de la Imagen o Renombre (Personas Naturales,Sociedades,"Influencers")'),
|
||||
(f'{company.id}_tax_withhold_profit_3440', '3440 2.75% Otras Retenciones Aplicables el 2,75%')
|
||||
]
|
||||
for xml_id, name in taxes_to_update:
|
||||
# There is no translation for name taxes in the l10n_ec data, which means we need to update the name for each language.
|
||||
active_langs = env['res.lang'].search([('active', '=', True)])
|
||||
for lang in active_langs:
|
||||
tax = env.ref(f'l10n_ec.{xml_id}', raise_if_not_found=False)
|
||||
if tax:
|
||||
tax.with_context(lang=lang.code).name = name
|
||||
|
||||
def update_ec_codes(cr, env):
|
||||
"""
|
||||
Update special fields for Ecuador, the code base and code applied in the taxes
|
||||
"""
|
||||
companies = env['res.company'].search([('chart_template_id', '=', env.ref('l10n_ec.l10n_ec_ifrs').id)])
|
||||
for company in companies:
|
||||
taxes_to_update = [
|
||||
(f'{company.id}_tax_withhold_profit_3440', '3440', '3940')
|
||||
]
|
||||
for xml_id, l10n_ec_code_base, l10n_ec_code_applied in taxes_to_update:
|
||||
cr.execute("UPDATE account_tax SET l10n_ec_code_base=%s, l10n_ec_code_applied=%s "
|
||||
"WHERE id=(SELECT res_id FROM ir_model_data WHERE module = 'l10n_ec' AND name=%s)",
|
||||
(l10n_ec_code_base, l10n_ec_code_applied, xml_id))
|
||||
|
||||
def inactivate_taxes_replaced(cr, env):
|
||||
"""
|
||||
Inactivate the taxes that were replaced by the new ones
|
||||
"""
|
||||
|
||||
companies = env['res.company'].search([('chart_template_id', '=', env.ref('l10n_ec.l10n_ec_ifrs').id)])
|
||||
for company in companies:
|
||||
taxes_to_inactivate = [
|
||||
f'{company.id}_tax_withhold_profit_304', # replaced by tax_withhold_profit_304_10
|
||||
f'{company.id}_tax_withhold_profit_304A', # replaced by tax_withhold_profit_304A_10
|
||||
f'{company.id}_tax_withhold_profit_304B', # replaced by tax_withhold_profit_304B_10
|
||||
f'{company.id}_tax_withhold_profit_304E', # replaced by tax_withhold_profit_304E_10
|
||||
f'{company.id}_tax_withhold_profit_309', # replaced by tax_withhold_profit_309_2_75
|
||||
f'{company.id}_tax_withhold_profit_314A', # replaced by tax_withhold_profit_314A_10
|
||||
f'{company.id}_tax_withhold_profit_314B', # replaced by tax_withhold_profit_314B_10
|
||||
f'{company.id}_tax_withhold_profit_314C', # replaced by tax_withhold_profit_314C_10
|
||||
f'{company.id}_tax_withhold_profit_314D', # replaced by tax_withhold_profit_314D_10
|
||||
f'{company.id}_tax_withhold_profit_320', # replaced by tax_withhold_profit_320_10
|
||||
f'{company.id}_tax_withhold_profit_322', # replaced by tax_withhold_profit_322_1
|
||||
f'{company.id}_tax_withhold_profit_319', # replaced by tax_withhold_profit_319_2
|
||||
]
|
||||
for xml_id in taxes_to_inactivate:
|
||||
cr.execute("UPDATE account_tax SET active=False "
|
||||
"WHERE id=(SELECT res_id FROM ir_model_data WHERE module = 'l10n_ec' AND name=%s)", (xml_id,))
|
||||
|
||||
def migrate(cr, version):
|
||||
env = api.Environment(cr, SUPERUSER_ID, {})
|
||||
update_taxes_from_templates(cr, 'l10n_ec.l10n_ec_ifrs')
|
||||
update_names(cr, env)
|
||||
update_ec_codes(cr, env)
|
||||
inactivate_taxes_replaced(cr, env)
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
||||
|
||||
from odoo.addons.account.models.chart_template import update_taxes_from_templates
|
||||
|
||||
def migrate(cr, version):
|
||||
# For new VAT taxes in 2024
|
||||
update_taxes_from_templates(cr, 'l10n_ec.l10n_ec_ifrs')
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
||||
|
||||
from odoo.addons.account.models.chart_template import update_taxes_from_templates
|
||||
|
||||
def migrate(cr, version):
|
||||
# For April 5 Withholding Tax Code Updates
|
||||
update_taxes_from_templates(cr, 'l10n_ec.l10n_ec_ifrs')
|
||||
|
|
@ -0,0 +1,47 @@
|
|||
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
||||
|
||||
from odoo.addons.account.models.chart_template import update_taxes_from_templates
|
||||
from odoo import api, SUPERUSER_ID
|
||||
|
||||
|
||||
def update_names(cr, env):
|
||||
"""
|
||||
Update the names in the taxes
|
||||
"""
|
||||
companies = env['res.company'].search([('chart_template_id', '=', env.ref('l10n_ec.l10n_ec_ifrs').id)])
|
||||
for company in companies:
|
||||
taxes_to_update = [
|
||||
(f'{company.id}_tax_vat_05_411_goods', 'IVA 5% (435, Bienes)'),
|
||||
(f'{company.id}_tax_vat_05_510_sup_01', 'IVA 5% (550, 01 Crédito IVA)')
|
||||
]
|
||||
for xml_id, name in taxes_to_update:
|
||||
# There is no translation for name taxes in the l10n_ec data, which means we need to update the name for each language.
|
||||
active_langs = env['res.lang'].search([('active', '=', True)])
|
||||
for lang in active_langs:
|
||||
tax = env.ref(f'l10n_ec.{xml_id}', raise_if_not_found=False)
|
||||
if tax:
|
||||
tax.with_context(lang=lang.code).name = name
|
||||
|
||||
|
||||
def update_ec_codes(cr, env):
|
||||
"""
|
||||
Update special fields for Ecuador, the code base and code applied in the taxes
|
||||
"""
|
||||
companies = env['res.company'].search([('chart_template_id', '=', env.ref('l10n_ec.l10n_ec_ifrs').id)])
|
||||
for company in companies:
|
||||
taxes_to_update = [
|
||||
(f'{company.id}_tax_vat_05_411_goods', '435', '445'),
|
||||
(f'{company.id}_tax_vat_05_510_sup_01', '550', '560'),
|
||||
]
|
||||
for xml_id, l10n_ec_code_base, l10n_ec_code_applied in taxes_to_update:
|
||||
cr.execute("UPDATE account_tax SET l10n_ec_code_base=%s, l10n_ec_code_applied=%s "
|
||||
"WHERE id=(SELECT res_id FROM ir_model_data WHERE module = 'l10n_ec' AND name=%s)",
|
||||
(l10n_ec_code_base, l10n_ec_code_applied, xml_id))
|
||||
|
||||
|
||||
def migrate(cr, version):
|
||||
# For May Withholding Tax Code Updates
|
||||
env = api.Environment(cr, SUPERUSER_ID, {})
|
||||
update_taxes_from_templates(cr, 'l10n_ec.l10n_ec_ifrs')
|
||||
update_ec_codes(cr, env)
|
||||
update_names(cr, env)
|
||||
Loading…
Add table
Add a link
Reference in a new issue