Skip to Content
Menu
This question has been flagged
1 Reply
1171 Views

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]        }

Avatar
Discard
Author

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.

Author

I think I figured it out. The rules for how these pieces have to be named are a little complicated.

Best Answer

Hello Christopher Piggott ,


Please refer the video: https://youtu.be/H7cGI23BHNs?si=F095OmTe2rewo7rR

I have shared video please checked and try after if you have any doubt let me know.


Hope this helps!

Thanks & Regards,

Name : Yahoo Baba

Email: yahoobaba077@gmail.com

Avatar
Discard
Related Posts Replies Views Activity
2
May 25
993
0
Mar 24
1047
2
Nov 16
5281
3
Feb 16
15910
3
Mar 15
8702