From 024150c4cfc268ef7ecca16e5841c575020d0ae8 Mon Sep 17 00:00:00 2001
From: Juliana <juliana@le-filament.com>
Date: Thu, 11 Mar 2021 14:06:28 +0100
Subject: [PATCH] [ADD] Add button on tree expense to manage justif

---
 views/hr_expense_views.xml | 62 ++++++++++++++++++++++++++++++++++++++
 1 file changed, 62 insertions(+)

diff --git a/views/hr_expense_views.xml b/views/hr_expense_views.xml
index 5b9e15b..eea25b4 100644
--- a/views/hr_expense_views.xml
+++ b/views/hr_expense_views.xml
@@ -40,5 +40,67 @@
                 </filter>
             </field>
         </record>
+
+        <record id="view_expenses_tree" model="ir.ui.view">
+            <field name="name">hr.expense.tree</field>
+            <field name="model">hr.expense</field>
+            <field name="inherit_id" ref="hr_expense.view_expenses_tree"/>
+            <field name="arch" type="xml">
+                <button name="action_get_attachment_view" position="replace">
+                    <field name="proof_file" invisible="1"/>
+                    <button name="%(adefpat_alfodoo.upload_file_wizard_action)d"
+                          string="Justif de frais"
+                          type="action"
+                          class="btn-outline-info btn-sm"
+                          attrs="{'invisible': [('proof_file', '!=', False)]}"
+                    />
+                    <button icon="fa-times"
+                            name="delete_file"
+                            string="Supprimer le fichier"
+                            class="text-danger"
+                            type="object"
+                            attrs="{'invisible': [('proof_file', '=', False)]}"
+                    />
+                    <button icon="/adefpat_alfodoo/static/src/img/alfresco-logo-16.png"
+                            name="get_content_details_url"
+                            string="Voir le fichier dans Alfresco"
+                            type="object"
+                            attrs="{'invisible': [('proof_file', '=', False)]}"
+                      />
+                </button>
+            </field>
+        </record>
+
+        <record id="view_hr_expense_sheet_form" model="ir.ui.view">
+            <field name="name">hr.expense.sheet.form</field>
+            <field name="model">hr.expense.sheet</field>
+            <field name="inherit_id" ref="hr_expense.view_hr_expense_sheet_form"/>
+            <field name="arch" type="xml">
+                <xpath expr="//notebook//page//field[@name='expense_line_ids']//tree//field[@name='attachment_number']" position="replace"/>
+                <xpath expr="//notebook//page//field[@name='expense_line_ids']//tree//button[@name='action_get_attachment_view']" position="replace">
+                    <field name="proof_file" invisible="1"/>
+                    <button name="%(adefpat_alfodoo.upload_file_wizard_action)d"
+                          string="Justif de frais"
+                          type="action"
+                          class="btn-outline-info btn-sm"
+                          attrs="{'invisible': [('proof_file', '!=', False)]}"
+                    />
+                    <button icon="fa-times"
+                            name="delete_file"
+                            string="Supprimer le fichier"
+                            class="text-danger"
+                            type="object"
+                            attrs="{'invisible': [('proof_file', '=', False)]}"
+                    />
+                    <button icon="/adefpat_alfodoo/static/src/img/alfresco-logo-16.png"
+                            name="get_content_details_url"
+                            string="Voir le fichier dans Alfresco"
+                            type="object"
+                            attrs="{'invisible': [('proof_file', '=', False)]}"
+                      />
+                </xpath>
+            </field>
+        </record>
+
     </data>
 </odoo>
-- 
GitLab