-
  Giving access rights of salesman to convert the lead into opportunity.
-
  !context
    uid: 'crm_res_users_salesman'
-
  In order to test the conversion of a lead into a opportunity,
-
  I set lead to open stage.
-
   !python {model: crm.lead}: |
     self.write(cr, uid, [ref("crm_case_3")],{'stage_id':ref("stage_lead1")})
-
  I check if the lead stage is "Open".
-
  !assert {model: crm.lead, id: crm.crm_case_3, string: Lead stage is Open}:
     - stage_id.sequence == 1
-
  I convert lead into opportunity for exiting customer.
-
  !python {model: crm.lead}: |
    self.convert_opportunity(cr, uid ,[ref("crm_case_3")], ref("base.res_partner_2"))
-
  I check details of converted opportunity.
-
  !python {model: crm.lead}: |
    lead = self.browse(cr, uid, ref('crm_case_3'))
    assert lead.type == 'opportunity', 'Lead is not converted to opportunity!'
    assert lead.partner_id.id == ref("base.res_partner_2"), 'Partner mismatch!'
    assert lead.stage_id.id == ref("stage_lead1"), 'Stage of opportunity is incorrect!'
-
  Now I schedule meeting with customer.
-
  !python {model: crm.lead}: |
    self.action_schedule_meeting(cr, uid, [ref('crm_case_3')])
-
  After communicated  with customer, I put some notes with contract details.
-
  !python {model: crm.lead}: |
    self.message_post(cr, uid, [ref('crm_case_3')], subject='Test note', body='Détails envoyés par le client sur ​​le FAX pour la qualité')
-
  I convert mass lead into opportunity customer.
-
  !python {model: crm.lead2opportunity.partner.mass}: |
    context.update({'active_model': 'crm.lead', 'active_ids': [ref("crm_case_13"), ref("crm_case_2")], 'active_id': ref("crm_case_13")})
    id = self.create(cr, uid, {'user_ids': [(6, 0, [ref('base.user_root')])], 'team_id': ref('sales_team.team_sales_department')}, context=context)
    self.mass_convert(cr, uid, [id], context=context)
-
  Now I check first lead converted on opportunity.
-
  !python {model: crm.lead}: |
    opp = self.browse(cr, uid, ref('crm_case_13'))
    assert opp.name == "Plan to buy 60 keyboards and mouses", "Opportunity name not correct"
    assert opp.type == 'opportunity', 'Lead is not converted to opportunity!'
    expected_partner = "Will McEncroe"
    assert opp.partner_id.name == expected_partner, 'Partner mismatch! %s vs %s' % (opp.partner_id.name, expected_partner)
    assert opp.stage_id.id == ref("stage_lead1"), 'Stage of probability is incorrect!'
-
  Then check for second lead converted on opportunity.
-
  !python {model: crm.lead}: |
    opp = self.browse(cr, uid, ref('crm_case_2'))
    assert opp.name == "Interest in Your New Software", "Opportunity name not correct"
    assert opp.type == 'opportunity', 'Lead is not converted to opportunity!'
    assert opp.stage_id.id == ref("stage_lead1"), 'Stage of probability is incorrect!'
-
  I loose the second opportunity
-
  !python {model: crm.lead}: |
    self.case_mark_lost(cr, uid, [ref("crm_case_2")])
-
  I check details of the opportunity after the loose
-
  !python {model: crm.lead}: |
    lead = self.browse(cr, uid, ref('crm_case_2'))
    assert lead.probability == 0.0, "Revenue probability should be 0.0!"
-
  I confirm review needs meeting.
-
  !python {model: calendar.event}: |
    context.update({'active_model': 'calendar.event'})
    self.write(cr, uid, [ref('calendar.calendar_event_4')], {'state': 'open'})
-
  I invite a user for meeting.
-
  !python {model: calendar.attendee}: |
    meeting_id = self.create(cr, uid, {'partner_id': ref('base.partner_root'), 'email': 'user@meeting.com' })
    self.do_accept(cr, uid, [meeting_id])
