From a566a3feb2a5edf71b5466285742d36d02ee8cb5 Mon Sep 17 00:00:00 2001
From: Juliana <juliana@le-filament.com>
Date: Wed, 5 Apr 2023 12:15:57 +0200
Subject: [PATCH] [UPD]Update template PDF invoice

---
 models/acc_operation.py     |   1 +
 report/account_template.xml | 147 ++++++++++++++++++++++++++++++------
 2 files changed, 127 insertions(+), 21 deletions(-)

diff --git a/models/acc_operation.py b/models/acc_operation.py
index 5f4dd25..14f4e97 100644
--- a/models/acc_operation.py
+++ b/models/acc_operation.py
@@ -337,6 +337,7 @@ class AccOperation(models.Model):
                 "power_cons": power_cons_tot,
                 "start_date": date_start,
                 "end_date": date_end,
+                "is_collectivite": producer_id.is_collectivite,
             }
         )
 
diff --git a/report/account_template.xml b/report/account_template.xml
index fdb47e4..28d48f3 100644
--- a/report/account_template.xml
+++ b/report/account_template.xml
@@ -194,17 +194,18 @@
                 <t t-else="">
                     <div class="page">
                         <div class="row mb32">
-                            <div class="col-3">
-                                <img
-                                    t-if="o.producer_id.image_1920"
-                                    t-att-src="image_data_uri(o.producer_id.image_1920)"
-                                    style="max-height: 80px;"
-                                    alt="Logo"
-                                />
-                                <h2 t-else="o.producer_id"/>
+                            <div class="col-4">
+                                <t t-if="o.producer_id.image_1920">
+                                    <img
+                                        t-att-src="image_data_uri(o.producer_id.image_1920)"
+                                        style="max-height: 80px;"
+                                        alt="Logo"
+                                    />
+                                </t>
+                                <t t-else=""><h4 t-esc="o.producer_id.name" /></t>
                             </div>
 
-                            <div class="col-9 text-center">
+                            <div class="col-8 text-center">
                                 <p class="font-weight-bold">
                                     <span
                                         class="text-uppercase mt0 "
@@ -266,8 +267,7 @@
                                     <span t-field="o.acc_delivery_id.zip" /> - <span
                                             t-field="o.acc_delivery_id.city"
                                         /><br /></t>
-                                    </p>
-                                <hr />
+                                </p>
                                 <div>
                                     <p>
                                         <span
@@ -299,7 +299,6 @@
                                             <span t-field="o.producer_id.origine"/><br/>
                                         </t>
                                     </p>
-                                    <hr />
                                     <h6 class="mt32 font-weight-bold">Pour répondre à vos questions</h6>
                                     <p class="mb-4">
                                         <span
@@ -463,7 +462,7 @@
 
                             </div>
                         </div>
-                        <div class="row mt-5">
+                        <div class="row mt-3">
                             <div class="col-12 font-italic">
                                 En cas de paiement anticipé, aucun escompte ne sera accordé. Indemnités pour frais de recouvrement en cas de retard de paiement : 40.00€ sauf frais  supplémentaires. Conformément à l’article L 441-6 du Code de commerce, en cas de non paiement à l'échéance, sera appliquée une pénalité de  retard équivalente à trois fois le taux d'intérêt légal en vigueur.
                             </div>
@@ -471,15 +470,17 @@
                         <t t-set="prmi_ids" t-value="o.line_ids.mapped('acc_injection_id')"/>
                         <t t-foreach="prmi_ids" t-as="injection">
                             <div class="row" style="page-break-before:always;">
-                                <div class="col-3">
-                                    <img
-                                        t-if="o.producer_id.image_1920"
-                                        t-att-src="image_data_uri(o.producer_id.image_1920)"
-                                        style="max-height: 80px;"
-                                        alt="Logo"
-                                    />
+                                <div class="col-4">
+                                    <t t-if="o.producer_id.image_1920">
+                                        <img
+                                            t-att-src="image_data_uri(o.producer_id.image_1920)"
+                                            style="max-height: 80px;"
+                                            alt="Logo"
+                                        />
+                                    </t>
+                                    <t t-else=""><h4 t-esc="o.producer_id.name" /></t>
                                 </div>
-                                <div class="col-9"></div>
+                                <div class="col-8"></div>
                             </div>
 
                             <div class="row mt-4 ">
@@ -658,6 +659,110 @@
                                 </div>
                             </div>
                         </t>
+<!--                        Partie pour les lignes de facture supplémentaires -->
+                            <div class="row" style="page-break-before:always;">
+                                <div class="col-4">
+                                    <t t-if="o.producer_id.image_1920">
+                                        <img
+                                            t-att-src="image_data_uri(o.producer_id.image_1920)"
+                                            style="max-height: 80px;"
+                                            alt="Logo"
+                                        />
+                                    </t>
+                                    <t t-else=""><h4 t-esc="o.producer_id.name" /></t>
+                                </div>
+                                <div class="col-8"></div>
+                            </div>
+
+                            <div class="row mt-4 ">
+                                <div class="col-12">
+                                    <div class="text-center text-uppercase mb-4">
+                                        <h4>Votre facture en détail</h4>
+                                        <span
+                                            class="text-uppercase mb-4 "
+                                        >Autoconsommation Collective <t
+                                                t-esc="o.acc_operation_id.name"
+                                        /></span><br />
+                                    </div>
+
+            <!--                    Table les lignes spécifiques -->
+                                    <h6 class="mt-4">
+                                        <span
+                                        class="text-uppercase mt0 "
+                                        >Frais divers / Régularisation</span></h6>
+                                    <table
+                                        class="table table-sm o_main_table"
+                                        name="account_line_table"
+                                    >
+                                        <thead>
+                                            <tr>
+                                                <th>Description</th>
+                                                <th class="text-center">Quantité</th>
+                                                <th class="text-center">Prix unitaire</th>
+                                                <t t-if="o.is_tva">
+                                                    <th class="text-center">Total HT</th>
+                                                    <th class="text-center">TVA</th>
+                                                </t>
+                                                <th class="text-center">Total TTC</th>
+                                            </tr>
+                                        </thead>
+                                        <tbody>
+                                            <t t-set="current_subtotal" t-value="0"/>
+                                            <t t-set="lines_sale" t-value="o.line_ids.filtered(lambda line: not line.acc_injection_id)" />
+                                            <t t-foreach="lines_sale" t-as="line">
+                                                <t t-set="current_subtotal" t-value="current_subtotal + line.price_total_ttc"/>
+                                                <tr class="">
+                                                    <td>
+                                                        <span
+                                                            t-field="line.description"
+                                                            t-options="{'widget': 'text'}"
+                                                        />
+                                                    </td>
+                                                    <td class="text-center">
+                                                        <span
+                                                            class="text-nowrap"
+                                                            t-field="line.quantity"
+                                                        /><span> kWh</span>
+                                                    </td>
+                                                    <td class="text-center">
+                                                        <span
+                                                            class="text-nowrap"
+                                                            t-field="line.price_unit"
+                                                        /><span> €/kWh</span>
+                                                    </td>
+                                                    <t t-if="o.is_tva">
+                                                        <td class="text-center">
+                                                            <span
+                                                                class="text-nowrap"
+                                                                t-field="line.price_total"
+                                                            />
+                                                        </td>
+                                                        <td class="text-center">
+                                                            <span
+                                                                class="text-nowrap"
+                                                                t-field="line.tax_id.name"
+                                                            />
+                                                        </td>
+                                                    </t>
+                                                    <td class="text-center">
+                                                        <span
+                                                            class="text-nowrap"
+                                                            t-field="line.price_total_ttc"
+                                                        />
+                                                    </td>
+                                                </tr>
+                                            </t>
+                                        </tbody>
+                                    </table>
+                                    <h6 class="is-subtotal text-right">
+                                        <strong class="mr-4">MONTANT TOTAL : </strong>
+                                        <span class="ml-4"
+                                            t-esc="current_subtotal"
+                                            t-options='{"widget": "monetary", "display_currency": o.currency_id}'
+                                        />
+                                    </h6>
+                                </div>
+                            </div>
                     </div>
                 </t>
 
-- 
GitLab