diff --git a/__manifest__.py b/__manifest__.py index 3812e95977c5bdf503b8014f4553548023c1646d..ebaf4badd3c6b2282fb535b9ec896cccb11b3f40 100755 --- a/__manifest__.py +++ b/__manifest__.py @@ -24,17 +24,18 @@ "datas/mail_data.xml", "datas/queue_job_data.xml", "datas/ir_sequence_data.xml", - # Reports + # Templates "templates/report_scop_bordereau.xml", "templates/report_scop_bordereau_payments.xml", "templates/report_scop_bordereau_refund.xml", # 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", + # Reports + "report/scop_contribution_report.xml", # Wizards "wizard/export_journal_wizard_view.xml", "wizard/scop_cotisation_cg_regul_wizard.xml", diff --git a/report/scop_contribution_report.py b/report/scop_contribution_report.py index 5f9a450241692aa45beb14812f1f952812e732c6..d4c0fa3fae675cbaab3ec1aae6101ad4e441c579 100644 --- a/report/scop_contribution_report.py +++ b/report/scop_contribution_report.py @@ -1,13 +1,41 @@ # © 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 import models, fields, api from odoo.exceptions import UserError class ScopContributionReport(models.Model): _inherit = "scop.contribution.report" + has_bordereau = fields.Boolean("Bordereau lié", compute="_compute_has_bordereau") + + # ------------------------------------------------------ + # Compute + # ------------------------------------------------------ + @api.multi + def _compute_has_bordereau(self): + contrib_cg = self.env.ref('cgscop_partner.riga_14397') + for contribution in self: + # exclude contribution before 2021 from RIGA + if contribution.year > '2020': + if contribution.type_contribution_id == contrib_cg: + bordereau = self.env['scop.bordereau'].search([ + ('partner_id', '=', self.partner_id.id), + ('year', '=', self.year), + ]) + if len(bordereau) == 1: + contribution.has_bordereau = True + else: + contribution.has_bordereau = False + else: + contribution.has_bordereau = False + else: + contribution.has_bordereau = False + + # ------------------------------------------------------ + # Button + # ------------------------------------------------------ def print_report_with_payment(self): bordereau = self.env['scop.bordereau'].search([ ('partner_id', '=', self.partner_id.id), diff --git a/report/scop_contribution_report.xml b/report/scop_contribution_report.xml new file mode 100644 index 0000000000000000000000000000000000000000..bdf5c4451458a18b10a3b0ab5e1582fcb31cf336 --- /dev/null +++ b/report/scop_contribution_report.xml @@ -0,0 +1,24 @@ +<?xml version="1.0" encoding="utf-8"?> +<odoo> + <data> + <!-- FORM VIEW --> + <record model="ir.ui.view" id="scop_contribution_report_cg_form"> + <field name="name">scop.contribution.report.cg.form</field> + <field name="model">scop.contribution.report</field> + <field name="inherit_id" ref="cgscop_cotisation.scop_contribution_report_form"/> + <field name="arch" type="xml"> + <xpath expr="//field[@name='payments']" position="before"> + <field name="has_bordereau" invisible="1"/> + <div attrs="{'invisible': [('has_bordereau', '=', False)]}" class="mt16 mb16"> + <button name="print_report_with_payment" + type="object" + string="Imprimer le bordereau" + icon="fa-file-pdf-o" + class="btn btn-sm btn-outline-info" + /> + </div> + </xpath> + </field> + </record> + </data> +</odoo> diff --git a/views/res_partner.xml b/views/res_partner.xml deleted file mode 100644 index 7a94d4751c49a116253a817910b4057fa22b12d9..0000000000000000000000000000000000000000 --- a/views/res_partner.xml +++ /dev/null @@ -1,20 +0,0 @@ -<?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