from odoo import models, fields, api

class Leads_report_wizard(models.TransientModel):
    _name = 'action_leads_report_wizard'
    _description = 'Leads Report Wizard'


    from_date = fields.Date(
        string="From Date",
        default=fields.Date.today 
    )
    to_date = fields.Date(
        string="To Date",
        default=fields.Date.today  
    )
    def generate_report(self):
        domain = []
        if self.from_date:
            domain.append(('entry_date', '>=', self.from_date))
        if self.to_date:
            domain.append(('entry_date', '<=', self.to_date))

        records = self.env['sos_inside_sales_leads'].search(domain)
        if not records:
            return {
                'type': 'ir.actions.client',
                'tag': 'display_notification',
                'params': {
                    'title': 'No Records Found',
                    'message': f'No records found',
                    'type': 'warning',
                    'sticky': False,
                }
            }

        return self.env.ref('sos_inside_sales.report_leads_html_action').report_action(
            [],
            data={
                'from_date': str(self.from_date),
                'to_date': str(self.to_date),
            }
        )


        