Skip to Content
เมนู
คุณต้องลงทะเบียนเพื่อโต้ตอบกับคอมมูนิตี้
คำถามนี้ถูกตั้งค่าสถานะ
2 ตอบกลับ
5248 มุมมอง

Is it possible to set paperformat in python when calling report_action function. I mean something like this:

self.env.ref(report_name).with_context(landscape=False, paperformat='my_paperformat').report_action([], data=data)

 
อวตาร
ละทิ้ง

Link custom paper format in QWEB Reports: https://goo.gl/kCH93K

คำตอบที่ดีที่สุด

hi Diego, 

What you can do is add your paperformat to your report. So that when you call the report, it will call the paperformat you have set. 

this is done in two ways : 
1- UI :

Activate the developer Mode then Go to Settings => Technical => reporting.

search for your report and go to form view. There' s a field for Paper format ( paperformat_id). select your paper format. 

2- Via code : 
you can get your report xml id to update the field papaerformat_id by setting the paperformat ref's id that you want.. 

report = self.env.ref('module.my_report')
report.paperformat_id = self.env.ref('module.my_paperformat_to_apply').id
report.report_action([], data=data)

Upvote if this helps. If not, you can write back.
Regards.
อวตาร
ละทิ้ง
ผู้เขียน

Thanks a lot Ibrahim! Option 2 is what I was looking for. Works great!

คำตอบที่ดีที่สุด

this is suboptimal - every time you are trying to change field in the database, better to override method `get_paperformat`

อวตาร
ละทิ้ง