| 1 |
from psycopg2.extras import execute_values |
| 2 |
|
| 3 |
# (rec_name_regex, name_en, desc_en, desc_ar, notes_en, tax_scope) |
| 4 |
TAX_VALUES_MAPPING = [ |
| 5 |
( |
| 6 |
r'^\d+_sa_local_sales_tax_0$', |
| 7 |
'0%', |
| 8 |
'Not Subject to VAT', |
| 9 |
'غير خاضعة لضريبة القيمة المضافة.', |
| 10 |
'Not Subject to VAT.', |
| 11 |
None, |
| 12 |
), |
| 13 |
( |
| 14 |
r'^\d+_sa_export_sales_tax_0$', |
| 15 |
'0% EX G', |
| 16 |
'Zero-rated exports - Export of Goods', |
| 17 |
'تصدير البضائع.', |
| 18 |
'Export of Goods.', |
| 19 |
'consu', |
| 20 |
), |
| 21 |
( |
| 22 |
r'^\d+_sa_exempt_sales_tax_0$', |
| 23 |
'0% EXT FS', |
| 24 |
'Exempt - Financial services mentioned in Article 29 of the VAT Regulations', |
| 25 |
'الخدمات المالية المذكورة في القانون 29 في لوائح ضريبة القيمة المضافة.', |
| 26 |
'Financial services mentioned in Article 29 of the VAT Regulations.', |
| 27 |
None, |
| 28 |
), |
| 29 |
] |
| 30 |
|
| 31 |
|
| 32 |
def migrate(cr, version): |
| 33 |
# Update names, descriptions, legal notes and JSONB translations |
| 34 |
execute_values(cr, """ |
| 35 |
WITH data(rec_name, name_en, desc_en, desc_ar, notes_en, tax_scope) AS ( |
| 36 |
VALUES %s |
| 37 |
) |
| 38 |
UPDATE account_tax AS t |
| 39 |
SET |
| 40 |
name = jsonb_build_object('en_US', data.name_en), |
| 41 |
description = jsonb_build_object('en_US', data.desc_en, 'ar_001', data.desc_ar), |
| 42 |
invoice_legal_notes = jsonb_build_object('en_US', data.notes_en), |
| 43 |
tax_scope = COALESCE(data.tax_scope, t.tax_scope) |
| 44 |
FROM ir_model_data AS imd |
| 45 |
JOIN data ON imd.name ~ data.rec_name |
| 46 |
WHERE imd.model = 'account.tax' |
| 47 |
AND imd.res_id = t.id; |
| 48 |
""", TAX_VALUES_MAPPING) |