[IMP]: crm: Implemented view_init in lead to opportunity
bzr revid: rpa@tinyerp.com-20100318090014-x6rto1sezw1edh69
This commit is contained in:
parent
82d77f3024
commit
ffc05c3d71
|
@ -114,6 +114,27 @@ class crm_lead2opportunity(osv.osv_memory):
|
||||||
'planned_revenue': fields.float('Expected Revenue'),
|
'planned_revenue': fields.float('Expected Revenue'),
|
||||||
'partner_id': fields.many2one('res.partner', 'Partner'),
|
'partner_id': fields.many2one('res.partner', 'Partner'),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
def view_init(self, cr, uid, fields, context=None):
|
||||||
|
"""
|
||||||
|
This function checks for precondition before wizard executes
|
||||||
|
@param self: The object pointer
|
||||||
|
@param cr: the current row, from the database cursor,
|
||||||
|
@param uid: the current user’s ID for security checks,
|
||||||
|
@param fields: List of fields for default value
|
||||||
|
@param context: A standard dictionary for contextual values
|
||||||
|
|
||||||
|
"""
|
||||||
|
lead_obj = self.pool.get('crm.lead')
|
||||||
|
|
||||||
|
for lead in lead_obj.browse(cr, uid, context.get('active_ids', [])):
|
||||||
|
if lead.state in ['done', 'cancel']:
|
||||||
|
raise osv.except_osv(_("Warning !"), _("Closed/Cancelled \
|
||||||
|
Leads Could not convert into Opportunity"))
|
||||||
|
if lead.state != 'open':
|
||||||
|
raise osv.except_osv(_('Warning !'), _('Lead should be in \
|
||||||
|
\'Open\' state before converting to Opportunity.'))
|
||||||
|
return True
|
||||||
|
|
||||||
def default_get(self, cr, uid, fields, context=None):
|
def default_get(self, cr, uid, fields, context=None):
|
||||||
"""
|
"""
|
||||||
|
@ -127,19 +148,13 @@ class crm_lead2opportunity(osv.osv_memory):
|
||||||
@return : default values of fields.
|
@return : default values of fields.
|
||||||
"""
|
"""
|
||||||
lead_obj = self.pool.get('crm.lead')
|
lead_obj = self.pool.get('crm.lead')
|
||||||
res = {}
|
res = super(crm_lead2opportunity, self).default_get(cr, uid, fields, context=context)
|
||||||
|
|
||||||
for lead in lead_obj.browse(cr, uid, context.get('active_ids', [])):
|
for lead in lead_obj.browse(cr, uid, context.get('active_ids', [])):
|
||||||
if lead.state in ['done', 'cancel']:
|
if 'name' in fields:
|
||||||
raise osv.except_osv(_("Warning !"), _("Closed/Cancelled \
|
res.update({'name': lead.partner_name})
|
||||||
Leads Could not convert into Opportunity"))
|
if 'partner_id' in fields:
|
||||||
if lead.state != 'open':
|
res.update({'partner_id': lead.partner_id and lead.partner_id.id or False})
|
||||||
raise osv.except_osv(_('Warning !'), _('Lead should be in \
|
|
||||||
\'Open\' state before converting to Opportunity.'))
|
|
||||||
|
|
||||||
res = {
|
|
||||||
'name': lead.partner_name,
|
|
||||||
'partner_id': lead.partner_id and lead.partner_id.id or False,
|
|
||||||
}
|
|
||||||
return res
|
return res
|
||||||
|
|
||||||
crm_lead2opportunity()
|
crm_lead2opportunity()
|
||||||
|
|
Loading…
Reference in New Issue