diff --git a/models/hr_expense.py b/models/hr_expense.py index a8db537bc0e5709aad2ac2e4532527f8c635e3af..be52f5245968278a5699ee88e3085ad506fba5ec 100644 --- a/models/hr_expense.py +++ b/models/hr_expense.py @@ -9,6 +9,7 @@ class AdefpatHrExpense(models.Model): _inherit = 'hr.expense' proof_file = fields.Char("Justificatif") + proof_file_timesheet = fields.Char("Justificatif", related='timesheet_id.proof_file') # ------------------------------------------------------ # Override ORM @@ -38,6 +39,25 @@ class AdefpatHrExpense(models.Model): properties = backend.get_cmis_repository().getFolder( expense.proof_file).getProperties() url = backend.get_content_details_url_from_props(properties) + return { + 'type': 'ir.actions.act_url', + 'url': url, + 'target': 'new', + }\ + + @api.multi + def get_content_details_url_timesheet(self): + # TODO: Refaire la fonction sans le type CMIS Folder + """ + Ouvre une nouvelle fenêtre avec le fichier + :return: ir.actions.act_url + """ + backend = self.env['cmis.backend'].search([], limit=1) + for expense in self: + if expense.proof_file_timesheet: + properties = backend.get_cmis_repository().getFolder( + expense.proof_file_timesheet).getProperties() + url = backend.get_content_details_url_from_props(properties) return { 'type': 'ir.actions.act_url', 'url': url, diff --git a/views/hr_expense_views.xml b/views/hr_expense_views.xml index eea25b406deaba7b69f5716107c34e1e2b297bc3..3820799d53b76a1aeb85f00b4349cf46b5f59676 100644 --- a/views/hr_expense_views.xml +++ b/views/hr_expense_views.xml @@ -21,10 +21,15 @@ type="object" attrs="{'invisible': [('proof_file', '=', False)]}"/> <field name="proof_file" invisible="1"/> - <button name="get_content_details_url" - string="Voir le justificatif" + <field name="proof_file_timesheet" invisible="1"/> + <button name="get_content_details_url" + string="Voir le justif de dépense" type="object" - attrs="{'invisible': [('proof_file', '=', False)]}"/> + attrs="{'invisible': [('proof_file', '=', False)]}"/> + <button name="get_content_details_url_timesheet" + string="Voir le justif de présence" + type="object" + attrs="{'invisible': [('proof_file_timesheet', '=', False)]}"/> </header> </field> </record> @@ -48,6 +53,7 @@ <field name="arch" type="xml"> <button name="action_get_attachment_view" position="replace"> <field name="proof_file" invisible="1"/> + <field name="proof_file_timesheet" invisible="1"/> <button name="%(adefpat_alfodoo.upload_file_wizard_action)d" string="Justif de frais" type="action" @@ -63,10 +69,16 @@ /> <button icon="/adefpat_alfodoo/static/src/img/alfresco-logo-16.png" name="get_content_details_url" - string="Voir le fichier dans Alfresco" + string="Voir le justif de dépense" type="object" attrs="{'invisible': [('proof_file', '=', False)]}" /> + <button icon="/adefpat_alfodoo/static/src/img/alfresco-logo-16.png" + name="get_content_details_url_timesheet" + string="Voir le justif de présence" + type="object" + attrs="{'invisible': [('proof_file_timesheet', '=', False)]}" + /> </button> </field> </record> @@ -79,6 +91,7 @@ <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"/> + <field name="proof_file_timesheet" invisible="1"/> <button name="%(adefpat_alfodoo.upload_file_wizard_action)d" string="Justif de frais" type="action" @@ -94,10 +107,16 @@ /> <button icon="/adefpat_alfodoo/static/src/img/alfresco-logo-16.png" name="get_content_details_url" - string="Voir le fichier dans Alfresco" + string="Voir le justif de dépense" type="object" attrs="{'invisible': [('proof_file', '=', False)]}" /> + <button icon="/adefpat_alfodoo/static/src/img/alfresco-logo-16.png" + name="get_content_details_url_timesheet" + string="Voir le justif de présence" + type="object" + attrs="{'invisible': [('proof_file_timesheet', '=', False)]}" + /> </xpath> </field> </record>