Skip to content
Extraits de code Groupes Projets
Valider dcf1a5b7 rédigé par Benjamin - Le Filament's avatar Benjamin - Le Filament
Parcourir les fichiers

[update] move print button on report form view, remove from tree view & add compute field

parent f00468c0
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
...@@ -24,17 +24,18 @@ ...@@ -24,17 +24,18 @@
"datas/mail_data.xml", "datas/mail_data.xml",
"datas/queue_job_data.xml", "datas/queue_job_data.xml",
"datas/ir_sequence_data.xml", "datas/ir_sequence_data.xml",
# Reports # Templates
"templates/report_scop_bordereau.xml", "templates/report_scop_bordereau.xml",
"templates/report_scop_bordereau_payments.xml", "templates/report_scop_bordereau_payments.xml",
"templates/report_scop_bordereau_refund.xml", "templates/report_scop_bordereau_refund.xml",
# Views # Views
"views/account_invoice.xml", "views/account_invoice.xml",
"views/res_config_settings.xml", "views/res_config_settings.xml",
"views/res_partner.xml",
"views/scop_cotisation_cg.xml", "views/scop_cotisation_cg.xml",
"views/scop_cotisation_simulation.xml", "views/scop_cotisation_simulation.xml",
"views/scop_liasse_fiscale.xml", "views/scop_liasse_fiscale.xml",
# Reports
"report/scop_contribution_report.xml",
# Wizards # Wizards
"wizard/export_journal_wizard_view.xml", "wizard/export_journal_wizard_view.xml",
"wizard/scop_cotisation_cg_regul_wizard.xml", "wizard/scop_cotisation_cg_regul_wizard.xml",
......
# © 2022 Le Filament (<http://www.le-filament.com>) # © 2022 Le Filament (<http://www.le-filament.com>)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). # 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 from odoo.exceptions import UserError
class ScopContributionReport(models.Model): class ScopContributionReport(models.Model):
_inherit = "scop.contribution.report" _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): def print_report_with_payment(self):
bordereau = self.env['scop.bordereau'].search([ bordereau = self.env['scop.bordereau'].search([
('partner_id', '=', self.partner_id.id), ('partner_id', '=', self.partner_id.id),
......
<?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>
<?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
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Veuillez vous inscrire ou vous pour commenter