-
  Give the access rights of Salesman to communicate with customer.
-
  !context
    uid: 'crm_res_users_salesman'
-
  Customer interested in our product, so he sends request by email to get more details.
-
  Mail script will fetch his request from mail server. Then I process that mail after read EML file.
-
  !python {model: mail.thread}: |
    request_file = open(openerp.modules.module.get_module_resource('crm','test', 'customer_request.eml'),'rb')
    request_message = request_file.read()
    self.message_process(cr, uid, 'crm.lead', request_message)
-
  After getting the mail, I check details of new lead of that customer.
-
  !python {model: crm.lead}: |
    lead_ids = self.search(cr, uid, [('email_from','=', 'Mr. John Right <info@customer.com>')])
    assert lead_ids and len(lead_ids), "Lead is not created after getting request"
    lead = self.browse(cr, uid, lead_ids[0], context=context)
    assert not lead.partner_id, "Customer should be a new one"
    assert lead.name == "Fournir votre devis avec le meilleur prix.", "Subject does not match"
-
  I reply his request with welcome message. TODO revert mail.mail to mail.compose.message (conversion to customer should be automatic).
-
  !python {model: mail.mail}: |
    lead_ids = self.pool.get('crm.lead').search(cr, uid, [('email_from','=', 'Mr. John Right <info@customer.com>')])
    context.update({'active_model': 'crm.lead','active_id': lead_ids[0]})
    id = self.create(cr, uid, {'body': "Merci de votre intérêt pour notre produit, nous vous contacterons bientôt. Bien à vous", 'email_from': 'sales@mycompany.com'}, context=context)
    try:
        self.send_mail(cr, uid, [id], context=context)
    except:
        pass
-
  Now, I convert him into customer and put him into regular customer list.
-
  !python {model: crm.lead}: |
    lead_ids = self.search(cr, uid, [('email_from','=', 'Mr. John Right <info@customer.com>')])
    self.handle_partner_assignation(cr, uid, lead_ids, context=context)
