mirror of
https://github.com/bringout/oca-ocb-l10n_me-africa.git
synced 2026-04-28 02:22:08 +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),
|
||||
),
|
||||
)
|
||||
|
|
@ -0,0 +1,48 @@
|
|||
from psycopg2.extras import execute_values
|
||||
|
||||
# (rec_name_regex, name_en, desc_en, desc_ar, notes_en, tax_scope)
|
||||
TAX_VALUES_MAPPING = [
|
||||
(
|
||||
r'^\d+_sa_local_sales_tax_0$',
|
||||
'0%',
|
||||
'Not Subject to VAT',
|
||||
'غير خاضعة لضريبة القيمة المضافة.',
|
||||
'Not Subject to VAT.',
|
||||
None,
|
||||
),
|
||||
(
|
||||
r'^\d+_sa_export_sales_tax_0$',
|
||||
'0% EX G',
|
||||
'Zero-rated exports - Export of Goods',
|
||||
'تصدير البضائع.',
|
||||
'Export of Goods.',
|
||||
'consu',
|
||||
),
|
||||
(
|
||||
r'^\d+_sa_exempt_sales_tax_0$',
|
||||
'0% EXT FS',
|
||||
'Exempt - Financial services mentioned in Article 29 of the VAT Regulations',
|
||||
'الخدمات المالية المذكورة في القانون 29 في لوائح ضريبة القيمة المضافة.',
|
||||
'Financial services mentioned in Article 29 of the VAT Regulations.',
|
||||
None,
|
||||
),
|
||||
]
|
||||
|
||||
|
||||
def migrate(cr, version):
|
||||
# Update names, descriptions, legal notes and JSONB translations
|
||||
execute_values(cr, """
|
||||
WITH data(rec_name, name_en, desc_en, desc_ar, notes_en, tax_scope) AS (
|
||||
VALUES %s
|
||||
)
|
||||
UPDATE account_tax AS t
|
||||
SET
|
||||
name = jsonb_build_object('en_US', data.name_en),
|
||||
description = jsonb_build_object('en_US', data.desc_en, 'ar_001', data.desc_ar),
|
||||
invoice_legal_notes = jsonb_build_object('en_US', data.notes_en),
|
||||
tax_scope = COALESCE(data.tax_scope, t.tax_scope)
|
||||
FROM ir_model_data AS imd
|
||||
JOIN data ON imd.name ~ data.rec_name
|
||||
WHERE imd.model = 'account.tax'
|
||||
AND imd.res_id = t.id;
|
||||
""", TAX_VALUES_MAPPING)
|
||||
Loading…
Add table
Add a link
Reference in a new issue