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

I am customizing the "account.report_invoice_document" View.

This is used to render both the PDF version and the Customer Portal version of an Invoice.

I would like the PDF to have some content that the Portal View will not and vice-versa.


Can I detect which is being rendered via a QWeb variable or another method so I can use conditional statements to render content?

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

These are the different URL's that are used:

  • PDF from Odoo backend: /report/download
  • Portal View: https://[server]/my/invoices/[id]?access_token=[guid]&report_type=html
  • PDF from Portal Download Action:  https://[server]/my/invoices/[id]?access_token=[guid]&report_type=pdf&download=True
  • PDF from Portal Print Action:  https://[server]/my/invoices/[id]?access_token=[guid]&report_type=pdf


So one way is to inspect the request like this to differentiate between the View and the PDF's:


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

Portal View: https://[server]/my/invoices/[id]?access_token=[guid]&report_type=html

is there any way to download custom template using portal view




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

Hi,

When rendering the portal view, the html version of the report is used. So if you need to show something only in portal  you can add a if condition using the variable report_type variable.

if report_type value is html, then it is portal and else it will be printing pdf.


So you can add condition as follows:  if report_type != 'html'


Thanks

Ảnh đại diện
Huỷ bỏ
Bài viết liên quan Trả lời Lượt xem Hoạt động
2
thg 6 25
1994
4
thg 5 24
6071
1
thg 5 23
3858
0
thg 7 17
3075
0
thg 3 16
3018