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

Hi all,

I need to make a report when generate with button click. also I need to show the odoo error message when report has no data. anyone can tell me the simple method to do this. 

Ảnh đại diện
Huỷ bỏ

Hello Rishan,

way : 1):Just check your data on button click which you are using / fetching in report and if not data found raise warning in that button's method it self.

way : 2) def render_html() / def get_report_values() ->(in v11) Do check in this method , this method will be called when you print any qweb report.just check here your data and raise warning accordingly !

Thanks!

Tác giả

Hi Dipak,

Thanks for your answer. do you have any example?

Câu trả lời hay nhất

Try this:

if docs:
    return {
'doc_ids': data['ids'],
'doc_model': data['model'],
'date_start': date_start,
'date_end': date_end,
'docs': docs,
    }
else:
    raise UserError(_("""No Data\n""") )
 


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

Hello Rishan,

You can do like below.

i n  render_html you can raise error message, if you set you report names like below

class YourModuleName (models.AbstractModel):

_ name = 'report.module_name.template_name'

@ api.multi
def render_html (self, docids, data = None):
    report_obj = self.env ['report']
    raise UserError (_ ('Example Error Message!')) 
    report = report_obj._get_report_from_name ('modulename.template_name' ) 
    docargs = {} 
    docargs.update ({
        'doc_ids': docids,
        'doc_model': 'mrp.production',
        'docs': mrp,
})
return report_obj.render ('modulename.template_name', docargs)

in report view

<report> .....

file = "modulename.template_name" 
name = "modulename.template_name"

and..

<template  ​id  ="template_name">

Please try like this if not worked, Please ask me.


Ảnh đại diện
Huỷ bỏ
Bài viết liên quan Trả lời Lượt xem Hoạt động
0
thg 3 19
2446
1
thg 2 21
3836
1
thg 4 25
1198
1
thg 9 24
1883
1
thg 7 24
1656