From e7d71d0ec3dbecf521c2df17031701828972604e Mon Sep 17 00:00:00 2001
From: "Daniel Kosky (dako)" <dako@odoo.com>
Date: Thu, 17 Aug 2023 12:17:58 +0000
Subject: [PATCH] [IMP] l10n_tr: KDV 20%
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Turkey has adapted its standard VAT from 18% up to 20%
This commit sets the 18% VAT taxes and its tax group to inactive and
introduces the respective 20% taxes and a 20% tax group.

closes odoo/odoo#132340

Task-id: None
Signed-off-by: Brice Bartoletti (bib) <bib@odoo.com>
Co-authored-by: Ramazan Subaşı <subasiramazan@gmail.com>
---
 addons/l10n_tr/__manifest__.py                |  2 +-
 addons/l10n_tr/data/account_data.xml          |  4 ++
 .../data/account_tax_template_data.xml        | 71 ++++++++++++++++++-
 .../1.1/end-migrate_update_taxes.py           |  6 ++
 4 files changed, 81 insertions(+), 2 deletions(-)
 create mode 100644 addons/l10n_tr/migrations/1.1/end-migrate_update_taxes.py

diff --git a/addons/l10n_tr/__manifest__.py b/addons/l10n_tr/__manifest__.py
index 0d0527aa42c5..ce0619fbfb8a 100644
--- a/addons/l10n_tr/__manifest__.py
+++ b/addons/l10n_tr/__manifest__.py
@@ -3,7 +3,7 @@
 
 {
     'name': 'Turkey - Accounting',
-    'version': '1.0',
+    'version': '1.1',
     'category': 'Accounting/Localizations/Account Charts',
     'description': """
 Türkiye için Tek düzen hesap planı şablonu Odoo Modülü.
diff --git a/addons/l10n_tr/data/account_data.xml b/addons/l10n_tr/data/account_data.xml
index b7901f14aa4d..4feb8d60987c 100644
--- a/addons/l10n_tr/data/account_data.xml
+++ b/addons/l10n_tr/data/account_data.xml
@@ -7,5 +7,9 @@
             <field name="name">KDV %18</field>
         </record>
 
+        <record id="tax_group_kdv_20" model="account.tax.group">
+            <field name="name">KDV 20%</field>
+        </record>
+
     </data>
 </odoo>
diff --git a/addons/l10n_tr/data/account_tax_template_data.xml b/addons/l10n_tr/data/account_tax_template_data.xml
index 82fd7650142d..eafe9cdf5354 100644
--- a/addons/l10n_tr/data/account_tax_template_data.xml
+++ b/addons/l10n_tr/data/account_tax_template_data.xml
@@ -1,6 +1,6 @@
 <?xml version="1.0" encoding="utf-8"?>
 <odoo>
-    <!-- account.tax.template -->
+    <!-- account.tax.template (pre-2023) -->
     <record id="tr_kdv_satis_sale_18" model="account.tax.template">
         <field name="sequence">11</field>
         <field name="description">KDV %18(sale)</field>
@@ -68,4 +68,73 @@
             }),
         ]"/>
     </record>
+
+    <!-- account.tax.template (introduced in July 2023) -->
+    <record id="tr_kdv_satis_sale_20" model="account.tax.template">
+        <field name="sequence">13</field>
+        <field name="description">KDV 20%</field>
+        <field name="name">20%</field>
+        <field name="price_include" eval="0"/>
+        <field name="amount">20</field>
+        <field name="amount_type">percent</field>
+        <field name="type_tax_use">sale</field>
+        <field name="chart_template_id" ref="l10ntr_tek_duzen_hesap"/>
+        <field name="tax_group_id" ref="tax_group_kdv_20"/>
+        <field name="invoice_repartition_line_ids" eval="[(5,0,0),
+            (0,0, {
+                'factor_percent': 100,
+                'repartition_type': 'base',
+            }),
+            (0,0, {
+                'factor_percent': 100,
+                'repartition_type': 'tax',
+                'account_id': ref('tr391'),
+            }),
+        ]"/>
+        <field name="refund_repartition_line_ids" eval="[(5,0,0),
+            (0,0, {
+                'factor_percent': 100,
+                'repartition_type': 'base',
+            }),
+            (0,0, {
+                'factor_percent': 100,
+                'repartition_type': 'tax',
+                'account_id': ref('tr191'),
+            }),
+        ]"/>
+    </record>
+
+    <record id="tr_kdv_satis_purchase_20" model="account.tax.template">
+        <field name="sequence">14</field>
+        <field name="description">KDV 20%</field>
+        <field name="name">20%</field>
+        <field name="price_include" eval="0"/>
+        <field name="amount">20</field>
+        <field name="amount_type">percent</field>
+        <field name="type_tax_use">purchase</field>
+        <field name="chart_template_id" ref="l10ntr_tek_duzen_hesap"/>
+        <field name="tax_group_id" ref="tax_group_kdv_20"/>
+        <field name="invoice_repartition_line_ids" eval="[(5,0,0),
+            (0,0, {
+                'factor_percent': 100,
+                'repartition_type': 'base',
+            }),
+            (0,0, {
+                'factor_percent': 100,
+                'repartition_type': 'tax',
+                'account_id': ref('tr391'),
+            }),
+        ]"/>
+        <field name="refund_repartition_line_ids" eval="[(5,0,0),
+            (0,0, {
+                'factor_percent': 100,
+                'repartition_type': 'base',
+            }),
+            (0,0, {
+                'factor_percent': 100,
+                'repartition_type': 'tax',
+                'account_id': ref('tr191'),
+            }),
+        ]"/>
+    </record>
 </odoo>
diff --git a/addons/l10n_tr/migrations/1.1/end-migrate_update_taxes.py b/addons/l10n_tr/migrations/1.1/end-migrate_update_taxes.py
new file mode 100644
index 000000000000..65fbea9df4d0
--- /dev/null
+++ b/addons/l10n_tr/migrations/1.1/end-migrate_update_taxes.py
@@ -0,0 +1,6 @@
+# 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):
+    update_taxes_from_templates(cr, 'l10n_tr.l10ntr_tek_duzen_hesap')
-- 
GitLab