Skip to content

Commit

Permalink
[IMP] minor imp of code style
Browse files Browse the repository at this point in the history
bzr revid: abo@openerp.com-20121107161142-c5iqr501mxbghy82
  • Loading branch information
Antonin Bourguignon committed Nov 7, 2012
1 parent efd48ff commit 48bf8e7
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 13 deletions.
3 changes: 2 additions & 1 deletion addons/crm/crm_lead.py
Original file line number Diff line number Diff line change
Expand Up @@ -676,14 +676,15 @@ def _lead_set_partner(self, cr, uid, lead, partner_id, context=None):

def convert_partner(self, cr, uid, ids, action='create', partner_id=False, context=None):
"""
This function convert partner based on action.
Convert partner based on action.
if action is 'create', create new partner with contact and assign lead to new partner_id.
otherwise assign lead to specified partner_id
"""
if context is None:
context = {}
partner_ids = {}
force_partner_id = partner_id
import pudb; pudb.set_trace();
for lead in self.browse(cr, uid, ids, context=context):
if action == 'create':
if not partner_id:
Expand Down
1 change: 0 additions & 1 deletion addons/crm/wizard/crm_lead_to_opportunity.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,6 @@ def _convert_opportunity(self, cr, uid, ids, vals, context=None):
context = {}
lead = self.pool.get('crm.lead')
res = False
# FIXME: automatically creating a partner ?
partner_ids_map = self._create_partner(cr, uid, ids, context=context)
lead_ids = vals.get('lead_ids', [])
team_id = vals.get('section_id', False)
Expand Down
19 changes: 8 additions & 11 deletions addons/crm/wizard/crm_lead_to_partner.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class crm_lead2partner(osv.osv_memory):
}
def view_init(self, cr, uid, fields, context=None):
"""
This function checks for precondition before wizard executes
Check for precondition before wizard executes.
"""
if context is None:
context = {}
Expand Down Expand Up @@ -69,22 +69,19 @@ def _select_partner(self, cr, uid, context=None):
return partner_id

def default_get(self, cr, uid, fields, context=None):
"""
This function gets default values
"""
res = super(crm_lead2partner, self).default_get(cr, uid, fields, context=context)
res = super(crm_lead2partner, self).default_get(cr, uid, fields, context=context)
partner_id = self._select_partner(cr, uid, context=context)

if 'partner_id' in fields:
res.update({'partner_id': partner_id})
if 'action' in fields:
res.update({'action': partner_id and 'exist' or 'create'})

return res

def open_create_partner(self, cr, uid, ids, context=None):
"""
This function Opens form of create partner.
Open form of create partner.
"""
view_obj = self.pool.get('ir.ui.view')
view_id = view_obj.search(cr, uid, [('model', '=', self._name), \
Expand All @@ -101,21 +98,21 @@ def open_create_partner(self, cr, uid, ids, context=None):

def _create_partner(self, cr, uid, ids, context=None):
"""
This function Creates partner based on action.
Create partner based on action.
"""
if context is None:
context = {}
lead = self.pool.get('crm.lead')
lead_ids = context and context.get('active_ids') or []
lead_ids = context.get('active_ids', [])
data = self.browse(cr, uid, ids, context=context)[0]
partner_id = data.partner_id and data.partner_id.id or False
return lead.convert_partner(cr, uid, lead_ids, data.action, partner_id, context=context)

def make_partner(self, cr, uid, ids, context=None):
"""
This function Makes partner based on action.
Make a partner based on action.
Only called from form view, so only meant to convert one lead at a time.
"""
# Only called from Form view, so only meant to convert one Lead.
lead_id = context and context.get('active_id') or False
partner_ids_map = self._create_partner(cr, uid, ids, context=context)
return self.pool.get('res.partner').redirect_partner_form(cr, uid, partner_ids_map.get(lead_id, False), context=context)
Expand Down

0 comments on commit 48bf8e7

Please sign in to comment.