Skip to content
Extraits de code Groupes Projets
Sélectionner une révision Git
  • 88910b070b308bb141b6d1fad1fa4600fc93b14c
  • 14.0 par défaut
  • 12.0 protégée
  • 13.0
4 résultats

__init__.py

Blame
  • union_sociale.py 1,55 Kio
    # Copyright 2021 Le Filament (<http://www.le-filament.com>)
    # License AGPL-3 or later (http://www.gnu.org/licenses/agpl.html).
    
    from werkzeug.exceptions import NotFound
    
    from odoo import http
    from odoo.http import request
    
    
    class UnionSocialeController(http.Controller):
        # ------------------------------------------------------
        # Routes
        # ------------------------------------------------------
        @http.route(
            ["/union-sociale/<adh>", "/union-sociale/<adh>/<year>"],
            type="http",
            auth="public",
            method=["GET"],
            csrf=False,
            website=False,
        )
        def get_union_sociale_pdf(self, adh, year=False):
            """
            URL pour générer le PDF de l'Union Sociale à joindre au
            bordereau de cotisation
            :params : adh -> num adhérent
            :params : year -> année du bordereau
            @return : PDF
            """
            partner_id = (
                request.env["res.partner"].sudo().search([("member_number", "=", adh)])
            )
            if partner_id:
                ctx = {"year": int(year)} if year else {}
                # Get report
                report = request.env.ref("cgscop_cotisation_cg.cgscop_union_sociale_report")
                # Create PDF
                pdf = report.sudo().with_context(ctx).render_qweb_pdf([partner_id.id])[0]
                pdfhttpheaders = [
                    ("Content-Type", "application/pdf"),
                    ("Content-Length", len(pdf)),
                ]
                # Return PDF
                return request.make_response(pdf, headers=pdfhttpheaders)
            else:
                raise NotFound()