From f00468c041f0f0eb3e5409b3ddb2f483f0c683a2 Mon Sep 17 00:00:00 2001 From: jordan <jordan@le-filament.com> Date: Thu, 27 Jan 2022 11:42:36 +0100 Subject: [PATCH] [add] button to download report bordereau with payment from scop_cotisation_report --- __init__.py | 1 + __manifest__.py | 1 + report/__init__.py | 4 ++++ report/scop_contribution_report.py | 21 +++++++++++++++++++++ views/res_partner.xml | 20 ++++++++++++++++++++ 5 files changed, 47 insertions(+) create mode 100755 report/__init__.py create mode 100644 report/scop_contribution_report.py create mode 100644 views/res_partner.xml diff --git a/__init__.py b/__init__.py index 6201253..f88059b 100755 --- a/__init__.py +++ b/__init__.py @@ -3,4 +3,5 @@ from . import controllers from . import models +from . import report from . import wizard diff --git a/__manifest__.py b/__manifest__.py index 54db846..3812e95 100755 --- a/__manifest__.py +++ b/__manifest__.py @@ -31,6 +31,7 @@ # Views "views/account_invoice.xml", "views/res_config_settings.xml", + "views/res_partner.xml", "views/scop_cotisation_cg.xml", "views/scop_cotisation_simulation.xml", "views/scop_liasse_fiscale.xml", diff --git a/report/__init__.py b/report/__init__.py new file mode 100755 index 0000000..530b049 --- /dev/null +++ b/report/__init__.py @@ -0,0 +1,4 @@ +# © 2020 Le Filament (<http://www.le-filament.com>) +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +from . import scop_contribution_report diff --git a/report/scop_contribution_report.py b/report/scop_contribution_report.py new file mode 100644 index 0000000..5f9a450 --- /dev/null +++ b/report/scop_contribution_report.py @@ -0,0 +1,21 @@ +# © 2022 Le Filament (<http://www.le-filament.com>) +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +from odoo import models +from odoo.exceptions import UserError + + +class ScopContributionReport(models.Model): + _inherit = "scop.contribution.report" + + def print_report_with_payment(self): + bordereau = self.env['scop.bordereau'].search([ + ('partner_id', '=', self.partner_id.id), + ('year', '=', self.year), + ]) + if len(bordereau) == 1: + return self.env.ref( + 'cgscop_cotisation_cg.cgscop_bordereau_report_with_payments' + ).report_action(bordereau) + else: + raise UserError('Pas de bordereau rattaché à cette cotisation.') diff --git a/views/res_partner.xml b/views/res_partner.xml new file mode 100644 index 0000000..7a94d47 --- /dev/null +++ b/views/res_partner.xml @@ -0,0 +1,20 @@ +<?xml version="1.0" encoding="utf-8"?> +<odoo> + <!-- Copyright 2022 Le Filament + License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). --> + <data> + + <record id="scop_contact_view_form" model="ir.ui.view"> + <field name="name">res.partner.scop.view.form</field> + <field name="model">res.partner</field> + <field name="inherit_id" ref="cgscop_cotisation.scop_contact_view_form"/> + <field name="arch" type="xml"> + <xpath expr="//page[@name='contribution']/field[@name='contribution_report_ids']/tree" position="inside"> + <button name="print_report_with_payment" type="object" + help="Télécharger l'état des paiements" icon="fa-file-pdf-o" + attrs="{'invisible':[('type_contribution_id','!=',%(cgscop_partner.riga_14397)d)]}"/> + </xpath> + </field> + </record> + </data> +</odoo> \ No newline at end of file -- GitLab