From bbd54e56ad535b1fed8dc2edf538137902df3ad8 Mon Sep 17 00:00:00 2001
From: benjamin <benjamin@le-filament.com>
Date: Mon, 8 Nov 2021 16:46:06 +0100
Subject: [PATCH] [update] invoice template

---
 __manifest__.py                       |  3 +++
 models/__init__.py                    |  1 +
 models/res_company.py                 | 13 ++++++++++++
 templates/report_invoice_document.xml | 29 +++++++++++++++++++++++++++
 views/res_company.xml                 | 22 ++++++++++++++++++++
 5 files changed, 68 insertions(+)
 create mode 100644 models/res_company.py
 create mode 100644 templates/report_invoice_document.xml
 create mode 100644 views/res_company.xml

diff --git a/__manifest__.py b/__manifest__.py
index 1031361..233c9b2 100755
--- a/__manifest__.py
+++ b/__manifest__.py
@@ -9,9 +9,12 @@
         'account',
     ],
     'data': [
+        # templates
+        'templates/report_invoice_document.xml',
         # views
         'views/account_move.xml',
         'views/account_journal.xml',
+        'views/res_company.xml',
     ],
     'qweb': [],
     'installable': True,
diff --git a/models/__init__.py b/models/__init__.py
index 56e136c..611ab07 100644
--- a/models/__init__.py
+++ b/models/__init__.py
@@ -3,3 +3,4 @@
 
 from . import account_journal
 from . import account_move
+from . import res_company
diff --git a/models/res_company.py b/models/res_company.py
new file mode 100644
index 0000000..190faa6
--- /dev/null
+++ b/models/res_company.py
@@ -0,0 +1,13 @@
+# Copyright 2021 Le Filament (<http://www.le-filament.com>)
+# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
+
+from odoo import fields, models
+
+
+class ResCompany(models.Model):
+    _inherit = 'res.company'
+
+    is_tax = fields.Boolean(
+        'TVA Applicable',
+        default=True
+    )
diff --git a/templates/report_invoice_document.xml b/templates/report_invoice_document.xml
new file mode 100644
index 0000000..e05d590
--- /dev/null
+++ b/templates/report_invoice_document.xml
@@ -0,0 +1,29 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright 2021 Le Filament
+     License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). -->
+
+<odoo>
+    <data>
+
+        <template id="afac_report_invoice_document" inherit_id="account.report_invoice_document">
+            <!-- Gestion de l'affichage de la TVA : tableau & total -->
+            <xpath expr="//th[@name='th_taxes']" position="attributes">
+                <attribute name="t-if">o.company_id.is_tax</attribute>
+            </xpath>
+            <xpath expr="//t[@name='account_invoice_line_accountable']/td[5]" position="attributes">
+                <attribute name="t-if">o.company_id.is_tax</attribute>
+            </xpath>
+            <xpath expr="//tr[hasclass('o_subtotal')]" position="attributes">
+                <attribute name="t-if">o.company_id.is_tax</attribute>
+            </xpath>
+            <xpath expr="//t[@t-foreach='o.amount_by_group']/tr" position="attributes">
+                <attribute name="t-if">o.company_id.is_tax</attribute>
+            </xpath>
+            <!-- Suppression affichage communication -->
+            <xpath expr="//p[@name='payment_communication']" position="attributes">
+                <attribute name="t-if">o.company_id.is_tax</attribute>
+            </xpath>
+        </template>
+
+    </data>
+</odoo>
\ No newline at end of file
diff --git a/views/res_company.xml b/views/res_company.xml
new file mode 100644
index 0000000..d96414c
--- /dev/null
+++ b/views/res_company.xml
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright 2021 Le Filament
+     License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). -->
+
+<odoo>
+    <data>
+
+        <!-- Form View -->
+
+        <record model="ir.ui.view" id="res_company_afac_form">
+            <field name="name">res.company.afac.form</field>
+            <field name="model">res.company</field>
+            <field name="inherit_id" ref="base.view_company_form"/>
+            <field name="arch" type="xml">
+                <xpath expr="//field[@name='vat']" position="before">
+                    <field name="is_tax" />
+                </xpath>
+            </field>
+        </record>
+
+    </data>
+</odoo>
-- 
GitLab