[MERGE] crm: improved and fixed customer creation, especially for lead to opportunity conversion. The wizard does not create a customer based on dummy values, such as only email or lead subject. A contact name is now required (partner_name, contact_name or email matching 'Name <email@adr.ess>' pattern.
bzr revid: tde@openerp.com-20130201143311-6kfh2z5eklx1c5bm
This commit is contained in:
+10
-4
@@ -716,7 +716,7 @@ class crm_lead(base_stage, format_address, osv.osv):
|
||||
|
||||
def _lead_create_contact(self, cr, uid, lead, name, is_company, parent_id=False, context=None):
|
||||
partner = self.pool.get('res.partner')
|
||||
vals = { 'name': name,
|
||||
vals = {'name': name,
|
||||
'user_id': lead.user_id.id,
|
||||
'comment': lead.description,
|
||||
'section_id': lead.section_id.id or False,
|
||||
@@ -736,11 +736,11 @@ class crm_lead(base_stage, format_address, osv.osv):
|
||||
'is_company': is_company,
|
||||
'type': 'contact'
|
||||
}
|
||||
partner = partner.create(cr, uid,vals, context)
|
||||
partner = partner.create(cr, uid, vals, context=context)
|
||||
return partner
|
||||
|
||||
def _create_lead_partner(self, cr, uid, lead, context=None):
|
||||
partner_id = False
|
||||
partner_id = False
|
||||
if lead.partner_name and lead.contact_name:
|
||||
partner_id = self._lead_create_contact(cr, uid, lead, lead.partner_name, True, context=context)
|
||||
partner_id = self._lead_create_contact(cr, uid, lead, lead.contact_name, False, partner_id, context=context)
|
||||
@@ -748,8 +748,14 @@ class crm_lead(base_stage, format_address, osv.osv):
|
||||
partner_id = self._lead_create_contact(cr, uid, lead, lead.partner_name, True, context=context)
|
||||
elif not lead.partner_name and lead.contact_name:
|
||||
partner_id = self._lead_create_contact(cr, uid, lead, lead.contact_name, False, context=context)
|
||||
elif lead.email_from and self.pool.get('res.partner')._parse_partner_name(lead.email_from, context=context)[0]:
|
||||
contact_name = self.pool.get('res.partner')._parse_partner_name(lead.email_from, context=context)[0]
|
||||
partner_id = self._lead_create_contact(cr, uid, lead, contact_name, False, context=context)
|
||||
else:
|
||||
partner_id = self._lead_create_contact(cr, uid, lead, lead.name, False, context=context)
|
||||
raise osv.except_osv(
|
||||
_('Warning!'),
|
||||
_('No customer name defined. Please fill one of the following fields: Company Name, Contact Name or Email ("Name <email@address>")')
|
||||
)
|
||||
return partner_id
|
||||
|
||||
def _lead_set_partner(self, cr, uid, lead, partner_id, context=None):
|
||||
|
||||
@@ -168,7 +168,7 @@
|
||||
</group>
|
||||
</group>
|
||||
<notebook colspan="4">
|
||||
<page string="Notes">
|
||||
<page string="Internal Notes">
|
||||
<field name="description"/>
|
||||
</page>
|
||||
<page string="Extra Info">
|
||||
|
||||
@@ -4,31 +4,37 @@
|
||||
!record {model: crm.lead, id: test_crm_lead_01}:
|
||||
type: 'lead'
|
||||
name: 'Test lead 1'
|
||||
email_from: 'Raoul Grosbedon <raoul@grosbedon.fr>'
|
||||
stage_id: stage_lead1
|
||||
-
|
||||
!record {model: crm.lead, id: test_crm_lead_02}:
|
||||
type: 'lead'
|
||||
name: 'Test lead 2'
|
||||
email_from: 'Raoul Grosbedon <raoul@grosbedon.fr>'
|
||||
stage_id: stage_lead1
|
||||
-
|
||||
!record {model: crm.lead, id: test_crm_lead_03}:
|
||||
type: 'lead'
|
||||
name: 'Test lead 3'
|
||||
email_from: 'Raoul Grosbedon <raoul@grosbedon.fr>'
|
||||
stage_id: stage_lead1
|
||||
-
|
||||
!record {model: crm.lead, id: test_crm_lead_04}:
|
||||
type: 'lead'
|
||||
name: 'Test lead 4'
|
||||
contact_name: 'Fabrice Lepoilu'
|
||||
stage_id: stage_lead1
|
||||
-
|
||||
!record {model: crm.lead, id: test_crm_lead_05}:
|
||||
type: 'lead'
|
||||
name: 'Test lead 5'
|
||||
contact_name: 'Fabrice Lepoilu'
|
||||
stage_id: stage_lead1
|
||||
-
|
||||
!record {model: crm.lead, id: test_crm_lead_06}:
|
||||
type: 'lead'
|
||||
name: 'Test lead 6'
|
||||
partner_name: 'Agrolait SuperSeed SA'
|
||||
stage_id: stage_lead1
|
||||
-
|
||||
!record {model: res.users, id: test_res_user_01}:
|
||||
|
||||
Reference in New Issue
Block a user