'CRM Lead Report
@param cr: the current row, from the database cursor'

@api.model_cr
def init(self):

    tools.drop_view_if_exists(self._cr, 'crm_lead_report_assign')
    self._cr.execute("\n                                                CREATE    OR    REPLACE    VIEW    crm_lead_report_assign    AS    (\n                                                                SELECT\n                                                                                c.id,\n                                                                                c.date_open    as    opening_date,\n                                                                                c.date_closed    as    date_closed,\n                                                                                c.date_assign,\n                                                                                c.user_id,\n                                                                                c.probability,\n                                                                                c.probability    as    probability_max,\n                                                                                c.type,\n                                                                                c.company_id,\n                                                                                c.priority,\n                                                                                c.team_id,\n                                                                                c.partner_id,\n                                                                                c.country_id,\n                                                                                c.planned_revenue,\n                                                                                c.partner_assigned_id,\n                                                                                p.grade_id,\n                                                                                p.date    as    partner_date,\n                                                                                c.planned_revenue*(c.probability/100)    as    probable_revenue,\n                                                                                1    as    nbr_cases,\n                                                                                c.create_date    as    create_date,\n                                                                                extract('epoch'    from    (c.write_date-c.create_date))/(3600*24)    as        delay_close,\n                                                                                extract('epoch'    from    (c.date_deadline    -    c.date_closed))/(3600*24)    as        delay_expected,\n                                                                                extract('epoch'    from    (c.date_open-c.create_date))/(3600*24)    as        delay_open\n                                                                FROM\n                                                                                crm_lead    c\n                                                                                left    join    res_partner    p    on    (c.partner_assigned_id=p.id)\n                                                )")
