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

I have a wizard that generates an Excel report. The report generation is working fine, but I want to automatically close the wizard window after the user downloads the report. Currently, after the report is downloaded, the wizard window remains open, and the user has to manually close it.


Here's the relevant code snippet from my action_generate_excel_report method:


def action_generate_excel_report(self):
    # ... (code to generate the Excel report and create an ir.attachment record)

    # Return an action to download the Excel report
    return {
        'type': 'ir.actions.act_url',
        'url': 'web/content/%s?download=true' % (doc.id),
        'target': 'self',
    }


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

This approach utilizes Python code within your wizard's confirmation button method.

def button_confirm(self): 

​# Your code to generate the Excel report... 

​# After successful report generation 

​return {'type': 'ir.actions.act_window_close'}

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

You need edit your code:
def action_generate_excel_report(self):
   # ... (code to generate the Excel report and create an ir.attachment record)
data = { content of excel }
report_action = self.env.ref('your_module.your_id_report_action').report_action(self, data)
​report_action.update({'close_on_report_download': True})
​return report_action
Hope to help you!


Ảnh đại diện
Huỷ bỏ
Tác giả

This works for pdf report not for excel report.

Bài viết liên quan Trả lời Lượt xem Hoạt động
2
thg 7 25
309
1
thg 12 21
4542
0
thg 4 18
6276
1
thg 5 25
1099
0
thg 11 24
1289