changes
This commit is contained in:
@@ -0,0 +1 @@
|
||||
from . import main
|
||||
40
fusion_labels/fusion_labels_print/controllers/main.py
Normal file
40
fusion_labels/fusion_labels_print/controllers/main.py
Normal file
@@ -0,0 +1,40 @@
|
||||
# Copyright © 2025 Nexa Systems Inc (https://nexasystems.ca)
|
||||
# @author: Nexa Systems Inc (support@nexasystems.ca)
|
||||
|
||||
# License OPL-1 (https://www.odoo.com/documentation/19.0/legal/licenses.html).
|
||||
|
||||
from odoo import http
|
||||
from odoo.http import request
|
||||
|
||||
from ..wizard.print_product_label import LABEL_ATTACHMENT_NAME
|
||||
class PrintPDF(http.Controller):
|
||||
|
||||
@http.route(
|
||||
'/print_label/<string:attachment_id>',
|
||||
type='http',
|
||||
auth='user',
|
||||
sitemap=False,
|
||||
)
|
||||
def print_label_pdf(self, attachment_id=None, **kwargs):
|
||||
if not attachment_id:
|
||||
return request.not_found()
|
||||
|
||||
try:
|
||||
attachment_id = int(attachment_id)
|
||||
except ValueError:
|
||||
return request.not_found()
|
||||
|
||||
attachment = request.env['ir.attachment'].sudo().search([
|
||||
('name', '=', LABEL_ATTACHMENT_NAME),
|
||||
('mimetype', '=', 'application/pdf'),
|
||||
('id', '=', attachment_id),
|
||||
])
|
||||
|
||||
if not attachment:
|
||||
return request.not_found()
|
||||
|
||||
pdf_url = f'/web/content/{attachment_id}'
|
||||
return request.render(
|
||||
'fusion_labels_print.print_product_label_pdf_template',
|
||||
{'title': 'Print Product Labels', 'pdf_url': pdf_url},
|
||||
)
|
||||
Reference in New Issue
Block a user