Bỏ qua để đến Nội dung
Menu
Câu hỏi này đã bị gắn cờ
1 Trả lời
1285 Lượt xem

I have a model




class DocumentWizard(models.TransientModel):
    _name = 'document.wizard'
    _description = 'Document Wizard'

    def print_contract_de_vente_first(self):

        # Get the report reference
        report_cond_general = self.env.ref('configurator.condition_general_report')
        condition_general = self.env['inokap.condition.general'].search([], limit=1)
        if not condition_general:
            raise UserError(_('No data found in condition.general model.'))

        # Render the PDF using the report name
       
        pdf_content, _ = report_cond_general._render_qweb_pdf(report_cond_general.report_name,condition_general.id)





​I know pdf_content is storing the correct pdf binary because when I try to debug and save it using this 

Python Writes bytes to file , the PDF show the right content.


pdf_content​ is still in binary 


The question is How to give this PDF to the user?


Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất

If you’re using a different web framework or context (like Odoo), the approach will be similar but adapted to the specifics of that framework. For instance, in Odoo, you would use the http.request.make_response method to create the response object. Remember to replace Flask and the route with the appropriate mechanism provided by your web framework.

Ảnh đại diện
Huỷ bỏ
Bài viết liên quan Trả lời Lượt xem Hoạt động
PDF reports Đã xử lý
5
thg 7 25
2249
Wrong PDF Format Đã xử lý
2
thg 3 24
2769
0
thg 11 22
2985
0
thg 9 17
5299
1
thg 3 15
8392