From 168a42a3a970ab3e585c9ff4a82b8e1fb629dfdf Mon Sep 17 00:00:00 2001
From: jordan <jordan@le-filament.com>
Date: Thu, 16 Sep 2021 17:53:02 +0200
Subject: [PATCH] [update] adapt template invoice for invoice adhesion

---
 __manifest__.py           |   4 +-
 report/report_invoice.xml | 126 ++++++++++++++++++++++++++++++++++++++
 2 files changed, 129 insertions(+), 1 deletion(-)
 create mode 100644 report/report_invoice.xml

diff --git a/__manifest__.py b/__manifest__.py
index f79bf00..cf338bb 100755
--- a/__manifest__.py
+++ b/__manifest__.py
@@ -1,12 +1,13 @@
 {
     "name": "CG SCOP - Adhésion Alfodoo",
     "summary": "CG SCOP - Adhésion Alfodoo",
-    "version": "12.0.1.1",
+    "version": "12.0.1.2",
     "author": "Le Filament",
     "license": "AGPL-3",
     "application": False,
     "installable": True,
     "depends": [
+        "cgscop_account",
         "cgscop_adhesion",
         "cgscop_partner_alfodoo",
         "cmis_field",
@@ -14,6 +15,7 @@
     "data": [
         "datas/mail_message_subtype.xml",
         "datas/mail_data.xml",
+        "report/report_invoice.xml",
         "views/scop_adhesion_file.xml",
     ],
 }
diff --git a/report/report_invoice.xml b/report/report_invoice.xml
new file mode 100644
index 0000000..69a8b60
--- /dev/null
+++ b/report/report_invoice.xml
@@ -0,0 +1,126 @@
+<?xml version="1.0" encoding="utf-8"?>
+<odoo>
+    <data>
+
+        <!-- Template invoice -->
+        <template id="scop_report_invoice_adhesion" inherit_id="cgscop_account.scop_report_invoice_document">
+
+            <!-- remplace le body pour supprimer le header et ajouter le footer -->
+            <xpath expr="//div[@name='hook_page']" position="after">
+                <div t-elif="o.journal_id == o.company_id.journal_adhesion_id" class="page mt32">
+                    <h2>
+                        <span t-if="o.type == 'out_invoice' and o.state in ('open', 'in_payment', 'paid')">Droits d'adhésion</span>
+                        <span t-if="o.type == 'out_invoice' and o.state == 'draft'">Brouillon adhésion</span>
+                        <span t-if="o.type == 'out_invoice' and o.state == 'cancel'">Annulation adhésion</span>
+                        <span t-field="o.number"/>
+                    </h2>
+
+                    <div id="informations" class="row mt32 mb32">
+                        <div class="col-auto mw-100 mb-2" t-if="o.name" name="description">
+                            <strong>Description:</strong>
+                            <p class="m-0" t-field="o.name"/>
+                        </div>
+                        <div class="col-auto mw-100 mb-2" t-if="o.date_invoice" name="invoice_date">
+                            <strong>Date:</strong>
+                            <p class="m-0" t-field="o.date_invoice"/>
+                        </div>
+                        <div class="col-auto mw-100 mb-2" t-if="o.date_due and o.type == 'out_invoice' and o.state in ('open', 'in_payment', 'paid')" name="due_date">
+                            <strong>Date d'échéance:</strong>
+                            <p class="m-0" t-field="o.date_due"/>
+                        </div>
+                    </div>
+
+                    <t t-set="display_discount" t-value="any([l.discount for l in o.invoice_line_ids])"/>
+
+                    <table class="table table-sm o_main_table" name="invoice_line_table">
+                        <thead>
+                            <tr>
+                                <t t-set="colspan" t-value="6"/>
+                                <th name="th_description" class="text-left"><span>Description</span></th>
+                                <th name="th_subtotal" class="text-right">
+                                    <span groups="account.group_show_line_subtotals_tax_excluded">Montant</span>
+                                    <span groups="account.group_show_line_subtotals_tax_included">Montant</span>
+                                </th>
+                            </tr>
+                        </thead>
+                        <tbody class="invoice_tbody">
+                            <t t-set="current_subtotal" t-value="0"/>
+
+                            <t t-foreach="o.invoice_line_ids" t-as="line">
+
+                                <t t-set="current_subtotal" t-value="current_subtotal + line.price_subtotal" groups="account.group_show_line_subtotals_tax_excluded"/>
+                                <t t-set="current_subtotal" t-value="current_subtotal + line.price_total" groups="account.group_show_line_subtotals_tax_included"/>
+
+                                <tr t-att-class="'bg-200 font-weight-bold o_line_section' if line.display_type == 'line_section' else 'font-italic o_line_note' if line.display_type == 'line_note' else ''">
+                                    <t t-if="not line.display_type" name="account_invoice_line_accountable">
+                                        <td name="account_invoice_line_name"><span t-field="line.name"/></td>
+                                        <td class="d-none"><span t-field="line.origin"/></td>
+                                        <td class="text-right o_price_total">
+                                            <span t-field="line.price_subtotal" groups="account.group_show_line_subtotals_tax_excluded"/>
+                                            <span t-field="line.price_total" groups="account.group_show_line_subtotals_tax_included"/>
+                                        </td>
+                                    </t>
+                                    <t t-if="line.display_type == 'line_section'">
+                                        <td colspan="99">
+                                            <span t-field="line.name"/>
+                                        </td>
+                                        <t t-set="current_section" t-value="line"/>
+                                        <t t-set="current_subtotal" t-value="0"/>
+                                    </t>
+                                    <t t-if="line.display_type == 'line_note'">
+                                        <td colspan="99">
+                                            <span t-field="line.name"/>
+                                        </td>
+                                    </t>
+                                </tr>
+                            </t>
+                        </tbody>
+                    </table>
+
+                    <div class="clearfix mb32">
+                        <div id="total" class="row">
+                            <div t-attf-class="#{'col-4' if report_type != 'html' else 'col-sm-7 col-md-5'} ml-auto">
+                                <table class="table table-sm" style="page-break-inside: avoid;">
+                                    <tr class="border-black o_total">
+                                        <td><strong>Total</strong></td>
+                                        <td class="text-right">
+                                            <span t-field="o.amount_total"/>
+                                        </td>
+                                    </tr>
+                                </table>
+                            </div>
+                        </div>
+                    </div>
+
+                    <p t-if="o.comment" name="comment">
+                        <span t-field="o.comment"/>
+                    </p>
+                    <p t-if="o.payment_term_id" name="payment_term">
+                        <span t-field="o.payment_term_id.note"/>
+                    </p>
+                    <p t-foreach="o.partner_banks_to_show()" t-as="partner_bank">
+                        <strong>Compte bancaire:</strong>
+                        <t t-if="partner_bank.bank_id">
+                            <t t-esc="partner_bank.bank_id.name + ('' if not partner_bank.bank_id.bic else ' (' + partner_bank.bank_id.bic + ')')" />
+                        </t>
+                        <t t-if="o.payment_mode_id.show_bank_account == 'full'">
+                            <span t-field="partner_bank.acc_number"/>
+                        </t>
+                        <t t-elif="o.payment_mode_id.show_bank_account == 'first'">
+                            <span t-esc="partner_bank.acc_number[:o.payment_mode_id.show_bank_account_chars] + '*' * (len(partner_bank.acc_number) - o.payment_mode_id.show_bank_account_chars)"/>
+                        </t>
+                        <t t-elif="o.payment_mode_id.show_bank_account == 'last'">
+                            <span t-esc="'*' * (len(partner_bank.acc_number) - o.payment_mode_id.show_bank_account_chars) + partner_bank.acc_number[-o.payment_mode_id.show_bank_account_chars:]"/>
+                        </t>
+                    </p>
+                    <p t-if="o.fiscal_position_id.note" name="note">
+                        <span t-field="o.fiscal_position_id.note"/>
+                    </p>
+
+                </div>
+            </xpath>
+
+        </template>
+
+    </data>
+</odoo>
-- 
GitLab