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.
Maak vandaag nog een account aan om te profiteren van exclusieve functies en deel uit te maken van onze geweldige community!
AanmeldenGerelateerde posts | Antwoorden | Weergaven | Activiteit | |
---|---|---|---|---|
|
0
mrt. 19
|
2339 | ||
Print a py3o report from wizard
Opgelost
|
|
1
feb. 21
|
3773 | |
|
1
apr. 25
|
1040 | ||
|
1
sep. 24
|
1737 | ||
|
1
jul. 24
|
1518 |
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?