Skip to Content
Meniu
Trebuie să fiți înregistrat pentru a interacționa cu comunitatea.
Această întrebare a fost marcată
4 Răspunsuri
17018 Vizualizări

I'm trying to create a report that uses some computed values that it gets from a few different models and than save it in a binary field. All other models that are needed are in relation with the one from which I call the get_pdf so that I gave it the current id.

document = self.env['report'].sudo().get_pdf(self.id, 'report_my_report')

My report code

class ReportMyReport(models.AbstractModel):
    _name = 'report.hr.report_my_report'

    @api.model
    def render_html(self, docids, data=None):
        data = self.env['hr.obrazec.obracun.place'].get_report_data(docids)

        docargs = {
            'doc_ids': self.ids,
            'doc_model': self.model,
            'data': data,
        }
        return self.env['report'].render('hr_izracun_place.report_my_report', docargs)

The get_report_data is a method from an AbstractModel that computes all the data needed and returns it in  a dict?

It takes the id from my top model.

So my problem is that I don't know if this is even the correct way of doing it. And it just won't work! So can some one please help with this and I'd like to know how to use the custom data in the QWEB report.

THANKS!


Imagine profil
Abandonează
Cel mai bun răspuns

I hope below links are helps you.

1- http://learnopenerp.blogspot.com/2016/11/how-to-create-qweb-reports-in-openerp.html

2- http://learnopenerp.blogspot.com/2016/09/how-to-create-custom-reports-in-odoo.html

Imagine profil
Abandonează
Autor

Nope... not even close!

Autor Cel mai bun răspuns

I'm now trying to pass text values with docargs but even they don't show on the report.  

    @api.model
    def render_html(self, docids, data=None):
        docargs = {
            'doc_ids': docids,
            'doc_model': 'report.hr.report_my_report',
'data': data, 'company': 'BLABLABLA', }         return self.env['report'].render('hr_izracun_place.report_my_report', docargs)

And I try to show it in my qweb report template with

<t t-esc="company"/>

But nothing is displayed!? 

------------------------------------------------

I haven't added the reports Abstract Models correctly into the __init__.py in the get_pdf you can pass ids that you want to use in the report, because it's the first parameter in render_html method. So you can than use those ids to search for records in models that you want.





Imagine profil
Abandonează
Related Posts Răspunsuri Vizualizări Activitate
3
mai 18
6985
3
apr. 22
16458
1
apr. 22
9015
2
dec. 24
7011
2
nov. 24
27413