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

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









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

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

Ảnh đại diện
Huỷ bỏ
Bài viết liên quan Trả lời Lượt xem Hoạt động
1
thg 4 23
2127
0
thg 3 23
1519
3
thg 8 24
3362
2
thg 7 23
3337
4
thg 6 23
3913