From 82436ebf321de40b911f0c74a3fb621fc3598a00 Mon Sep 17 00:00:00 2001
From: Benjamin <benjamin@le-filament.com>
Date: Wed, 11 Mar 2020 16:43:40 +0100
Subject: [PATCH] =?UTF-8?q?[add]=20gestion=20adresse=20=C3=A9tablissement?=
 =?UTF-8?q?=20secondaire?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 models/res_company.py       |  5 +++++
 views/report_templates.xml  | 18 ++++++++++++++----
 views/res_company_views.xml |  7 +++++++
 3 files changed, 26 insertions(+), 4 deletions(-)

diff --git a/models/res_company.py b/models/res_company.py
index e0c6555..6bb0f9d 100644
--- a/models/res_company.py
+++ b/models/res_company.py
@@ -10,3 +10,8 @@ class ResCompanyInvoice(models.Model):
     cgv = fields.Html('CGV')
     oec = fields.Char('OEC')
     forme_juridique = fields.Char('Forme Juridique')
+    has_facility = fields.Boolean('Etablissement secondaire ?', default=False)
+    facility_street = fields.Char('Rue')
+    facility_street2 = fields.Char('Rue 2')
+    facility_zip = fields.Char('Code Postal')
+    facility_city = fields.Char('Ville')
diff --git a/views/report_templates.xml b/views/report_templates.xml
index ddee168..b758f57 100644
--- a/views/report_templates.xml
+++ b/views/report_templates.xml
@@ -11,10 +11,20 @@
                     </div>
                     <div class="col-6 text-right mb4">
                         <h4 class="mt0" t-field="company.report_header"/>
-                        <div name="company_address" class="mb4">
-                            <span class="company_address" t-field="company.partner_id"
-                                t-options='{"widget": "contact", "fields": ["address", "name"], "no_marker": true}'/>
-                        </div>
+                        <t t-if="company.has_facility">
+                            <div name="facility_address" class="mb4">
+                                <span t-field="company.partner_id.name"/><br/>
+                                <span t-field="company.facility_street"/><br/>
+                                <t t-if="company.facility_street2"><span t-field="company.facility_street2"/><br/></t>
+                                <span t-field="company.facility_zip"/> <span t-field="company.facility_city"/>
+                            </div>
+                        </t>
+                        <t t-else="">
+                            <div name="company_address" class="mb4">
+                                <span class="company_address" t-field="company.partner_id"
+                                    t-options='{"widget": "contact", "fields": ["address", "name"], "no_marker": true}'/>
+                            </div>
+                        </t>
                     </div>
                 </div>
                 </div>
diff --git a/views/res_company_views.xml b/views/res_company_views.xml
index 6c88c88..c8acf2c 100644
--- a/views/res_company_views.xml
+++ b/views/res_company_views.xml
@@ -7,6 +7,13 @@
             <field name="model">res.company</field>
             <field name="inherit_id" ref="base.view_company_form"/>
             <field name="arch" type="xml">
+                <xpath expr="//notebook/page/group/group" position="inside">
+                    <field name="has_facility" widget="boolean_toggle"/>
+                    <field name="facility_street" attrs="{'invisible': [('has_facility', '!=', True)]}"/>
+                    <field name="facility_street2" attrs="{'invisible': [('has_facility', '!=', True)]}"/>
+                    <field name="facility_zip" attrs="{'invisible': [('has_facility', '!=', True)]}"/>
+                    <field name="facility_city" attrs="{'invisible': [('has_facility', '!=', True)]}"/>
+                </xpath>
                 <xpath expr="//field[@name='website']" position="after">
                     <field name="forme_juridique"/>
                     <field name="cgv"/>
-- 
GitLab