'This test case set the next activity on a lead, log another, and schedule a third.'

def test_crm_activity_next_action(self):

    self.lead.write({'next_activity_id': self.activity1.id})
    self.lead._onchange_next_activity_id()
    self.assertEqual(self.lead.title_action, self.activity1.description, 'Activity    title    should    be    the    same    on    the    lead    and    on    the    chosen    activity')
    wizard = self.env['crm.activity.log'].sudo(self.crm_salesman.id).create({'note': 'Content    of    the    activity    to    log', 'lead_id': self.lead.id})
    wizard.onchange_lead_id()
    wizard.write({'next_activity_id': self.activity2.id})
    wizard.action_log()
    self.assertFalse(self.lead.next_activity_id.id, 'No    next    activity    should    be    set    on    lead,    since    we    jsut    log    another    activity')
    self.env['crm.activity.log'].sudo(self.crm_salesman.id).create({'next_activity_id': self.activity3.id, 'note': 'Content    of    the    activity    to    log', 'lead_id': self.lead.id})
    wizard.onchange_lead_id()
    wizard.write({'next_activity_id': self.activity3.id})
    wizard.onchange_next_activity_id()
    wizard.action_schedule()
    delta_days = (fields.Date.from_string(self.lead.date_action) - date.today()).days
    self.assertEqual(self.activity3.days, delta_days, 'The    action    date    should    be    in    the    number    of    days    set    up    on    the    activity    3')
    self.assertEqual(self.lead.title_action, self.activity3.description, 'Activity    title    should    be    the    same    on    the    lead    and    on    the    activity    3')
