Перейти к содержимому
Меню
Чтобы взаимодействовать с сообществом, необходимо зарегистрироваться.
Этот вопрос был отмечен
1 Ответить
1230 Представления

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









"
Аватар
Отменить
Лучший ответ

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

Аватар
Отменить
Related Posts Ответы Просмотры Активность
1
апр. 23
1809
0
мар. 23
1291
3
авг. 24
2924
2
июл. 23
2742
4
июн. 23
3323