Ir al contenido
Menú
Se marcó esta pregunta
1 Responder
1225 Vistas

I have created 2 recrods, action report and template for pdf, but I have never defined the docs variable in the model, so how can Odoo understand it, or is it defined by default somewhere? So what if I want to define additional variables like "text1" : "hello" to use in the template? Thanks All​


"


​In PDF
​test.people
​qweb-pdf
​test_component.test_people_report_template
​test_component.test_people_report_template

​report








People









"
Avatar
Descartar
Mejor respuesta

Hi,

In odoo while printing PDF reports the docs are passing in the return of the function "def _get_report_values(self, docids, data=None)" as a key value pair in the dictionary. This value will be called in to XML template of the report. . If you want to pass extra data , you can pass it in the function as key ,value
example:    

def _get_report_values(self, docids, data=None):
        return {
            'doc_ids': docids,
            'doc_model': 'your.model',
            'docs': self.env['your.model'].browse(docids),
            'data': data,
            'company': self.env.company
        }

In the above the data are passed to the XML file as key value pairs.


For more please refer:

https://www.cybrosys.com/blog/how-to-create-pdf-report-in-odoo-16


Hope it helps

Avatar
Descartar
Publicaciones relacionadas Respuestas Vistas Actividad
1
abr 23
1804
0
mar 23
1288
3
ago 24
2859
2
jul 23
2719
4
jun 23
3314