İçereği Atla
Menü
Bu soru işaretlendi

In my instance of Odoo 15 with Studio I created several PDF reports for the quotes in the sales module. To view these reports I have to click 'print' ('imprimir' in my language) and it downloads the PDF. I need a way that I can view the PDF from the Odoo page without it downloading the PDF file to my PC. Mainly I want that when I press the 'print' button (or it can also be another button) the preview of the PDF report appears on the page instead of downloading as usual


This is what currently happens when I want to see one of those reports:



I'm trying to create a preview of this report with some python code that I got in another odoo forum post:


#In models.py
class report_sale_preview(models.Model):
    _inherit = 'sale.order'
    preview = fields.Html('Report Preview')
    def generate_preview(self):
        html = self.env['report'].get_html(self, 'sale.report_saleorder')
       #html = self.get_html(self, 'sale.report_saleorder')
        self.write({'preview': html})
        return True


But I have this error:

RPC_ERROR

Odoo Server Error

Traceback (most recent call last):

  File "/home/odoo/src/odoo/odoo/addons/base/models/http.py", line 301, in _handle_exception

    raise exception.with_traceback(None) from new_cause

KeyError: 'report'


Avatar
Vazgeç
Üretici

This is the code in views.xml

<record model="ir.ui.view" id="solt_report_preview_form_view">
<field name="name">sale.order.report.preview.form</field>
<field name="model">sale.order</field>
<field name="inherit_id" ref="sale.view_order_form"/>
<field name="arch" type="xml">
<xpath expr="//page[1]" position="after">
<page string="Report Preview">
<header>
<button name="generate_preview" type="object" string="Vista Previa"/>
</header>
<sheet>
<field name="preview"/>
</sheet>
</page>
</xpath>
</field>
</record>

İlgili Gönderiler Cevaplar Görünümler Aktivite
3
Tem 24
6070
0
Kas 23
1269
1
Ara 22
3347
1
Kas 22
3748
0
Eki 22
2561