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

[add] print bordereau extranet function

parent b608f609
Branches
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
# © 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 _, fields, models import base64
from odoo import SUPERUSER_ID, _, fields, models
from odoo.exceptions import UserError from odoo.exceptions import UserError
...@@ -39,7 +41,7 @@ class ScopContributionReport(models.Model): ...@@ -39,7 +41,7 @@ class ScopContributionReport(models.Model):
contribution.has_bordereau = False contribution.has_bordereau = False
# ------------------------------------------------------ # ------------------------------------------------------
# Button # Button / Action
# ------------------------------------------------------ # ------------------------------------------------------
def print_report_with_payment(self): def print_report_with_payment(self):
bordereau = ( bordereau = (
...@@ -63,6 +65,32 @@ class ScopContributionReport(models.Model): ...@@ -63,6 +65,32 @@ class ScopContributionReport(models.Model):
else: else:
raise UserError(_("Pas de bordereau rattaché à cette cotisation.")) raise UserError(_("Pas de bordereau rattaché à cette cotisation."))
def print_contribution(self):
self.ensure_one()
bordereau = (
self.env["scop.bordereau"]
.sudo()
.search(
[
("partner_id", "=", self.partner_id.id),
("year", "=", self.year),
("state", "not in", ["draft", "cancel"]),
]
)
)
if len(bordereau) == 1:
report_sudo = self.env.ref(
"cgscop_cotisation_cg.cgscop_bordereau_report"
).sudo()
bordereau_pdf = report_sudo.with_user(SUPERUSER_ID)._render_qweb_pdf(
bordereau.id
)[0]
return base64.b64encode(bordereau_pdf)
else:
raise UserError(
_("Impossible de télécharger le bordereau associé à cette cotisation.")
)
# ------------------------------------------------------ # ------------------------------------------------------
# Business method # Business method
# ------------------------------------------------------ # ------------------------------------------------------
......
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