from odoo import models, api
from odoo.exceptions import UserError  # for debug

class LeadsHtmlReport(models.AbstractModel):
    _name = 'report.sos_inside_sales.report_leads_html_template'
    _description = 'Leads HTML Report'

    @api.model
    def _get_report_values(self, docids, data=None):
        if not data:
            raise UserError("No data received in report")

        domain = []
        if data.get('from_date'):
            domain.append(('entry_date', '>=', data['from_date']))
        if data.get('to_date'):
            domain.append(('entry_date', '<=', data['to_date']))
        docs = self.env['sos_inside_sales_leads'].search(domain)
        if not docs:
            raise UserError("No records found for report")

        return {
            'docs': docs,
            'from_date': data['from_date'],
            'to_date': data['to_date'],
        }
