Skip to Content
मेन्यू
This question has been flagged
1 Reply
9275 Views

I've created a many2one field which holds every report in the odoo. How to select the report default by it's model name as a filter?

Avatar
Discard
Best Answer

Hello Yuvaraj,

def default_report_template(self):
act_model = self.env.context.get('active_model')
active_model_id = self.env['ir.model'].search([('name','=',act_model)]).id
filtered_report = self.env['ir.actions.report'].search([('binding_model_id','=',active_model_id)], limit=1)
return filtered_report and filtered_report.id or False

report_templates = fields.Many2one('ir.actions.report', default=default_report_template)

Thanks & Regards,
Email: odoo@aktivsoftware.com
Skype: kalpeshmaheshwari

Avatar
Discard
Related Posts Replies Views Activity
2
मार्च 24
1524
1
दिस॰ 21
5234
2
अप्रैल 21
11342
3
अक्तू॰ 18
40789
2
जुल॰ 15
4786