Debian Codegraph @

addons/l10n_sa/migrations/2.1/pre-migrate.py

raw symbols SCIP
1 from odoo.tools import SQL
2
3
4 def migrate(cr, version):
5 rename_map = {
6 "1. Standard Rates 15% (Base)": "1(B)",
7 "1. Standard Rates 15% (Tax)": "1(T)",
8 "3. Local Sales Subject to 0% (Base)": "3(B)",
9 "4. Export Sales (Base)": "4(B)",
10 "5. Exempt Sales (Base)": "5(B)",
11 "7. Standard rated 15% Purchases (Base)": "7(B)",
12 "7. Standard rated 15% Purchases (Tax)": "7(T)",
13 "9. Imports subject to reverse charge mechanism (Base)": "9(B)",
14 "9. Imports subject to reverse charge mechanism (Tax)": "9(T)",
15 "8. Taxable Imports 15% Paid to Customs (Base)": "8(B)",
16 "8. Taxable Imports 15% Paid to Customs (Tax)": "8(T)",
17 "10. Zero Rated Purchases (Base)": "10(B)",
18 "11. Exempt Purchases (Base)": "11(B)",
19 "Withholding Tax 5% (Rental) (Base)": "1(B)_W_G",
20 "Withholding Tax 5% (Rental) (Tax)": "1(T)_W_G",
21 "Withholding Tax 5% (Tickets or Air Freight) (Base)": "2(B)_W_G",
22 "Withholding Tax 5% (Tickets or Air Freight) (Tax)": "2(T)_W_G",
23 "Withholding Tax 5% (International Telecommunication)(Base)": "3(B)_W_G",
24 "Withholding Tax 5% (International Telecommunication)(Tax)": "3(T)_W_G",
25 "Withholding Tax 5% (Distributed Profits) (Base)": "4(B)_W_G",
26 "Withholding Tax 5% (Distributed Profits) (Tax)": "4(T)_W_G",
27 "Withholding Tax 5% (Insurance & Reinsurance) (Base)": "5(B)_W_G",
28 "Withholding Tax 5% (Insurance & Reinsurance) (Tax)": "5(T)_W_G",
29 "Withholding Tax 15% (Royalties)(Base)": "6(B)_W_G",
30 "Withholding Tax 15% (Royalties)(Tax)": "6(T)_W_G",
31 "Withholding Tax 15% (Others)(Base)": "7(B)_W_G",
32 "Withholding Tax 15% (Others)(Tax)": "7(T)_W_G",
33 "Withholding Tax 20% (Managerial)(Base)": "8(B)_W_G",
34 "Withholding Tax 20% (Managerial)(Tax)": "8(T)_W_G",
35 }
36
37 sql_name_mappings_list = []
38 for old_name, new_name in rename_map.items():
39 sql_name_mappings_list.append(
40 SQL(
41 "WHEN %s THEN jsonb_build_object('en_US', %s)",
42 old_name,
43 new_name,
44 )
45 )
46
47 cr.execute(
48 SQL(
49 """
50 UPDATE account_account_tag
51 SET name = CASE name->>'en_US'
52 %s
53 ELSE name
54 END
55 WHERE applicability = 'taxes'
56 AND country_id = (SELECT id FROM res_country WHERE code = 'SA')
57 """,
58 SQL("\n").join(sql_name_mappings_list),
59 ),
60 )