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.
Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:
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.
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""") )
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.
Create an account today to enjoy exclusive features and engage with our awesome community!
Sign upRelated Posts | Replies | Views | Activity | |
---|---|---|---|---|
|
0
Mar 19
|
2071 | ||
|
1
Feb 21
|
3483 | ||
|
1
Apr 25
|
240 | ||
|
1
Sep 24
|
1118 | ||
|
1
Jul 24
|
971 |
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!
Hi Dipak,
Thanks for your answer. do you have any example?