mirror of
https://github.com/bringout/oca-ocb-l10n_me-africa.git
synced 2026-04-28 08:22:02 +02:00
19.0 vanilla
This commit is contained in:
parent
c5006a6999
commit
80293571e7
420 changed files with 21812 additions and 44297 deletions
|
|
@ -0,0 +1,36 @@
|
|||
from odoo import SUPERUSER_ID, api
|
||||
|
||||
|
||||
def migrate(cr, version):
|
||||
""" Remove the tags on these taxes to avoid having clearly misconfigured ones """
|
||||
tax_xmlid_regex = "_sa_(?:local_sales_tax_0|export_sales_tax_0|exempt_sales_tax_0|purchases_tax_0|exempt_purchases_tax|rcp_tax_15)$"
|
||||
cr.execute(
|
||||
"""
|
||||
WITH tags_to_delete AS (
|
||||
SELECT tag_rel.*
|
||||
FROM account_account_tag_account_tax_repartition_line_rel AS tag_rel
|
||||
JOIN account_tax_repartition_line AS rep_line
|
||||
ON rep_line.id = tag_rel.account_tax_repartition_line_id
|
||||
JOIN account_tax AS tax
|
||||
ON tax.id = rep_line.tax_id
|
||||
JOIN ir_model_data AS imd_taxes
|
||||
ON imd_taxes.res_id = tax.id
|
||||
AND imd_taxes.model = 'account.tax'
|
||||
AND imd_taxes.module = 'account'
|
||||
JOIN res_company company
|
||||
ON company.chart_template = 'sa'
|
||||
WHERE rep_line.repartition_type = 'tax'
|
||||
AND imd_taxes.name ~ ('^' || company.id || %s)
|
||||
)
|
||||
DELETE
|
||||
FROM account_account_tag_account_tax_repartition_line_rel AS tag_rel
|
||||
USING tags_to_delete t
|
||||
WHERE tag_rel.account_tax_repartition_line_id = t.account_tax_repartition_line_id
|
||||
AND tag_rel.account_account_tag_id = t.account_account_tag_id;
|
||||
""",
|
||||
[tax_xmlid_regex],
|
||||
)
|
||||
|
||||
env = api.Environment(cr, SUPERUSER_ID, {})
|
||||
for company in env["res.company"].search([("chart_template", "=", "sa")], order="parent_path"):
|
||||
env["account.chart.template"].try_loading("sa", company)
|
||||
|
|
@ -0,0 +1,60 @@
|
|||
from odoo.tools import SQL
|
||||
|
||||
|
||||
def migrate(cr, version):
|
||||
rename_map = {
|
||||
"1. Standard Rates 15% (Base)": "1(B)",
|
||||
"1. Standard Rates 15% (Tax)": "1(T)",
|
||||
"3. Local Sales Subject to 0% (Base)": "3(B)",
|
||||
"4. Export Sales (Base)": "4(B)",
|
||||
"5. Exempt Sales (Base)": "5(B)",
|
||||
"7. Standard rated 15% Purchases (Base)": "7(B)",
|
||||
"7. Standard rated 15% Purchases (Tax)": "7(T)",
|
||||
"9. Imports subject to reverse charge mechanism (Base)": "9(B)",
|
||||
"9. Imports subject to reverse charge mechanism (Tax)": "9(T)",
|
||||
"8. Taxable Imports 15% Paid to Customs (Base)": "8(B)",
|
||||
"8. Taxable Imports 15% Paid to Customs (Tax)": "8(T)",
|
||||
"10. Zero Rated Purchases (Base)": "10(B)",
|
||||
"11. Exempt Purchases (Base)": "11(B)",
|
||||
"Withholding Tax 5% (Rental) (Base)": "1(B)_W_G",
|
||||
"Withholding Tax 5% (Rental) (Tax)": "1(T)_W_G",
|
||||
"Withholding Tax 5% (Tickets or Air Freight) (Base)": "2(B)_W_G",
|
||||
"Withholding Tax 5% (Tickets or Air Freight) (Tax)": "2(T)_W_G",
|
||||
"Withholding Tax 5% (International Telecommunication)(Base)": "3(B)_W_G",
|
||||
"Withholding Tax 5% (International Telecommunication)(Tax)": "3(T)_W_G",
|
||||
"Withholding Tax 5% (Distributed Profits) (Base)": "4(B)_W_G",
|
||||
"Withholding Tax 5% (Distributed Profits) (Tax)": "4(T)_W_G",
|
||||
"Withholding Tax 5% (Insurance & Reinsurance) (Base)": "5(B)_W_G",
|
||||
"Withholding Tax 5% (Insurance & Reinsurance) (Tax)": "5(T)_W_G",
|
||||
"Withholding Tax 15% (Royalties)(Base)": "6(B)_W_G",
|
||||
"Withholding Tax 15% (Royalties)(Tax)": "6(T)_W_G",
|
||||
"Withholding Tax 15% (Others)(Base)": "7(B)_W_G",
|
||||
"Withholding Tax 15% (Others)(Tax)": "7(T)_W_G",
|
||||
"Withholding Tax 20% (Managerial)(Base)": "8(B)_W_G",
|
||||
"Withholding Tax 20% (Managerial)(Tax)": "8(T)_W_G",
|
||||
}
|
||||
|
||||
sql_name_mappings_list = []
|
||||
for old_name, new_name in rename_map.items():
|
||||
sql_name_mappings_list.append(
|
||||
SQL(
|
||||
"WHEN %s THEN jsonb_build_object('en_US', %s)",
|
||||
old_name,
|
||||
new_name,
|
||||
)
|
||||
)
|
||||
|
||||
cr.execute(
|
||||
SQL(
|
||||
"""
|
||||
UPDATE account_account_tag
|
||||
SET name = CASE name->>'en_US'
|
||||
%s
|
||||
ELSE name
|
||||
END
|
||||
WHERE applicability = 'taxes'
|
||||
AND country_id = (SELECT id FROM res_country WHERE code = 'SA')
|
||||
""",
|
||||
SQL("\n").join(sql_name_mappings_list),
|
||||
),
|
||||
)
|
||||
Loading…
Add table
Add a link
Reference in a new issue