From f2e12c9c5ec56a87ffb974bcb8c6fb61095d7faa Mon Sep 17 00:00:00 2001
From: benjamin <benjamin@le-filament.com>
Date: Thu, 18 Jan 2024 17:45:55 +0100
Subject: [PATCH] [ADD] convocation

---
 models/training_training.py        |  9 ++++-
 templates/report_convocation.xml   | 53 ++++++++++++++++++++++--------
 views/res_config_settings_view.xml | 14 ++++----
 views/training_training_view.xml   |  4 +++
 4 files changed, 59 insertions(+), 21 deletions(-)

diff --git a/models/training_training.py b/models/training_training.py
index a35568a..f57d694 100644
--- a/models/training_training.py
+++ b/models/training_training.py
@@ -105,7 +105,8 @@ class Training(models.Model):
         selection=[("draft", "Brouillon"), ("current", "Accepté"), ("done", "Réalisé")],
         default="draft",
     )
-    place = fields.Text(string="Lieu de la formation")
+    place = fields.Char(string="Lieu de la formation")
+    place_detail = fields.Text(string="Détails du lieu")
     company_id = fields.Many2one(
         comodel_name="res.company",
         string="Company",
@@ -118,12 +119,18 @@ class Training(models.Model):
     plan = fields.Char(string="Dispositif OPCO")
     meanings = fields.Text("Dispositif formation")
     is_vat = fields.Boolean("TVA 20% applicable", default=True)
+    training_type_id = fields.Many2one(
+        comodel_name="training.type",
+        string="Type de formation",
+    )
     payment_term_id = fields.Many2one(
         comodel_name="account.payment.term",
         string="Condition de règlement",
         check_company=True,
         domain="['|', ('company_id', '=', False), ('company_id', '=', company_id)]",
     )
+    email_contact = fields.Char("Email contact formation")
+    equipment = fields.Text(string="Équipement/éléments nécessaires pour la formation")
 
     # ------------------------------------------------------
     # Override ORM
diff --git a/templates/report_convocation.xml b/templates/report_convocation.xml
index 35eff4e..fe2a0ee 100644
--- a/templates/report_convocation.xml
+++ b/templates/report_convocation.xml
@@ -14,17 +14,17 @@
 
                         <div class="page">
                             <div class="convention training_layout">
-                                <div class="row">
-                                    <div class="offset-9 col-3">
+                                <div class="row mb-4">
+                                    <div class="offset-8 col-4">
                                         <p>
                                             À <t t-if="student.student_id.title"><t t-out="student.student_id.title.name" /> </t><t t-out="student.student_id.lastname" class="text-uppercase" /> <t t-out="student.student_id.firstname"/>
                                             <br />
-                                            <t t-out="doc.company_id.city" />, le <t t-out="doc.date_convocation" />
+                                            <t t-out="doc.company_id.city" />, le <t t-out="doc.date_convocation" t-options="{'widget': 'date', 'format': 'dd/MM/yyyy'}" />
                                         </p>
                                     </div>
                                 </div>
 
-                                <div class="row">
+                                <div class="row mb-4">
                                     <div class="col-12 text-center">
                                         <h1 class="text-uppercase">Convocation à une formation</h1>
                                     </div>
@@ -32,7 +32,7 @@
 
                                 <div class="row">
                                     <div class="col-12">
-                                        <p t-if="student.student_id.title" class="mb-5">
+                                        <p t-if="student.student_id.title" class="mb-2">
                                             <t t-out="student.student_id.title.name" />,
                                         </p>
                                         <p>
@@ -44,17 +44,42 @@
                                             <t t-out="doc.course_id.objective" />
                                         </p>
                                         <p>
-                                            Le programme détaillé de cette formation est joint en annexe.
-                                            Pour toute demande d’information concernant cette formation, vous pouvez vous adresser à :
+                                            Le programme détaillé de cette formation est joint en annexe.<br />
+                                            Pour toute demande d’information concernant cette formation, vous pouvez vous adresser à : <a t-attf-href="mailto:{{doc.email_contact}}"><t t-out="doc.email_contact" /></a>
+                                        </p>
+                                        <p>
+                                            Cette formation se déroulera :
+                                            <ul>
+                                                <li t-if="doc.training_type_id">au format suivant : <span t-out="doc.training_type_id.name" class="fw-bold text-decoration-underline" /><br /></li>
+                                                <li>
+                                                    aux dates suivantes :
+                                                    <ul>
+                                                        <li t-foreach="doc.session_ids" t-as="session">
+                                                           <t t-out="session.date" t-options="{'widget': 'datetime', 'format': 'dd/MM/yyyy'}" /> de <t t-out="session.date" t-options="{'widget': 'datetime', 'format': 'HH\hmm'}" /> à <t t-out="session.date + relativedelta(hours=session.date_delay)" t-options="{'widget': 'datetime', 'format': 'HH:mm'}" />
+                                                        </li>
+                                                    </ul>
+                                                </li>
+                                            </ul>
+                                        </p>
+                                        <p>
+                                            Lieu : <span t-out="doc.place" class="fw-bold" />
+                                            <t t-if="doc.place_detail">
+                                                <br/><span t-field="doc.place_detail" class="fw-italic" />
+                                            </t>
+                                        </p>
+                                        <p t-if="doc.equipment">
+                                            Nous vous prions pour le bon déroulé de la formation d'apporter les éléments suivants : <br/>
+                                            <span t-field="doc.equipment" />
+                                        </p>
+                                        <p>
+                                            <span class="fw-bold">Situations particulières</span><br/>
+                                            Pour toute difficulté ou handicap, veuillez contacter <a t-attf-href="mailto:{{doc.email_contact}}"><t t-out="doc.email_contact" /></a> pour voir les éventuelles adaptations à prévoir.
+                                        </p>
+                                        <p>
+                                            Nous vous prions d’agréer, <t t-if="student.student_id.title"><t t-out="student.student_id.title.name" />, </t>l’expression de nos cordiales salutations. <br />
+                                            Fait à <span t-field="doc.company_id.city" />, le <span t-field="doc.date_convocation" />
                                         </p>
                                     </div>
-
-
-
-                                    <p>
-                                        Nous vous prions d’agréer, <t t-if="student.student_id.title"><t t-out="student.student_id.title.name" />, </t>l’expression de nos cordiales salutations. <br />
-                                        Fait à <span t-field="doc.company_id.city" />, le <span t-field="doc.date_convention" />
-                                    </p>
                                 </div>
                             </div>
                         </div>
diff --git a/views/res_config_settings_view.xml b/views/res_config_settings_view.xml
index 7abc481..8643c4f 100644
--- a/views/res_config_settings_view.xml
+++ b/views/res_config_settings_view.xml
@@ -31,12 +31,12 @@
                                     <div class="row mt16">
                                         <label
                                             for="training_number"
-                                            class="col-lg-6 o_light_label"
+                                            class="col-lg-6"
                                         />
                                         <field name="training_number" />
                                     </div>
                                     <div class="row mt16">
-                                        <div class="col-12 text-muted">
+                                        <div class="col-12 fw-bold">
                                             Conditions spéciales à ajouter en fin de convention
                                         </div>
                                         <div class="col-12">
@@ -105,10 +105,12 @@
                                         <field name="text_font" />
                                     </div>
                                      <div class="row mt16">
-                                        <label
-                                            for="logo_ids"
-                                            class="col-lg-6 o_light_label"
-                                        />
+                                         <div class="col-lg-6">
+                                             <label for="logo_ids" />
+                                             <p class="text-muted">
+                                                 Les logos sont affichés à la fin de la page de programme
+                                             </p>
+                                         </div>
                                          <field name="logo_ids" mode="kanban">
                                              <kanban delete="1">
                                                  <field name="name" />
diff --git a/views/training_training_view.xml b/views/training_training_view.xml
index ef0bae2..9f16a0c 100644
--- a/views/training_training_view.xml
+++ b/views/training_training_view.xml
@@ -41,6 +41,7 @@
                         <group>
                             <field name="customer_id" required="1" />
                             <field name="course_id" required="1" />
+                            <field name="training_type_id" options="{'no_create': 1}" />
                             <field name="date_begin" widget="date" required="1" />
                             <field name="date_end" widget="date" required="1" />
                             <field
@@ -56,10 +57,13 @@
                         </group>
                         <group>
                             <field name="date_convocation" />
+                            <field name="email_contact" required="1" />
                             <field name="signin_person" required="1" />
                             <field name="signin_function" required="1" />
                             <field name="place" required="1" />
+                            <field name="place_detail" />
                             <field name="meanings" />
+                            <field name="equipment" />
                         </group>
                     </group>
                     <group string="Infos Financières">
-- 
GitLab