I need to make a report that includes the lead_properties in a crm.lead but with the lead properties properly exported - names for the fields from the crm.team record, and value names if it's a selection. I figured this would also be a good way to try making my first custom report in a module.
I was able to create the module, get it to add itself to the CRM/Reporting menu, and invoke it, but I'm not getting any data. The template is being invoked, just no rows.
The report itself looks like
model="crm.lead"
string="Custom CRM Lead Report"
report_type="qweb-pdf"
file="custom_crm_lead_report.report_template"
name="custom_crm_lead_report.report_template" />
I have tried a bunch of different ways to get sample data in, but my generate_report() method doesn't ever get called. That's in addition to the fact that I'm probably not returning the correct thing.
Do I need to do something in the report description xml to tell it "and this is the method you call to get the rows of data" ?
class CRMLeadReport(models.Model): _name = 'crm.lead.report' _description = 'Custom CRM Lead Report'
@api.model
def generate_report(self):
_logger.error("OH NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO")
sample_data = [
{'lead_name': 'Lead 1', 'team_name': 'Sales Team A', 'custom_data': 'Sample Data 1'},
{'lead_name': 'Lead 2', 'team_name': 'Sales Team B', 'custom_data': 'Sample Data 2'},
{'lead_name': 'Lead 3', 'team_name': 'Sales Team C', 'custom_data': 'Sample Data 3'}
] return { 'docs': [sample_data] }
I think I did everything in that video. Also I followed github.com/vyngt
/odoo-sample-app which shows a couple of reports. I'm quite certain these line up:
<field name="model">crm.lead.coe_report</field>
class COELeadReport(models.Model):
_name = 'crm.lead.coe_report'
This model definitely gets loaded (I can see it in settings / technical / database / model).
so everything seems to be linked together, but my get_report_values never gets called:
@api.model
def _get_report_values(self, docids, data=None)
I need to check your code first, and then I'll provide the correct answer. Can you please share the code?
if you need more help feel free to contact i'll guide you.
https://github.com/wz2b/odoo-report-example
I think I figured it out. The rules for how these pieces have to be named are a little complicated.