[FIX] crm: correct mass conversion wizard defaults, fixes crm tests
bzr revid: odo@openerp.com-20120824161320-mdfqibfe53v2op79
This commit is contained in:
parent
d19ad1ff4b
commit
971756e016
|
@ -73,7 +73,7 @@
|
||||||
I convert mass lead into opportunity customer.
|
I convert mass lead into opportunity customer.
|
||||||
-
|
-
|
||||||
!python {model: crm.lead2opportunity.partner.mass}: |
|
!python {model: crm.lead2opportunity.partner.mass}: |
|
||||||
context.update({'active_model': 'crm.lead', 'active_ids': [ref("crm_case_11"), ref("crm_case_2")], 'active_id': ref("crm_case_4")})
|
context.update({'active_model': 'crm.lead', 'active_ids': [ref("crm_case_11"), ref("crm_case_2")], 'active_id': ref("crm_case_11")})
|
||||||
id = self.create(cr, uid, {'user_ids': [ref('base.user_root')], 'section_id': ref('crm.section_sales_department')}, context=context)
|
id = self.create(cr, uid, {'user_ids': [ref('base.user_root')], 'section_id': ref('crm.section_sales_department')}, context=context)
|
||||||
self.mass_convert(cr, uid, [id], context=context)
|
self.mass_convert(cr, uid, [id], context=context)
|
||||||
-
|
-
|
||||||
|
@ -83,7 +83,8 @@
|
||||||
opp = self.browse(cr, uid, ref('crm_case_11'))
|
opp = self.browse(cr, uid, ref('crm_case_11'))
|
||||||
assert opp.name == "Need estimated cost for new project", "Opportunity name not correct"
|
assert opp.name == "Need estimated cost for new project", "Opportunity name not correct"
|
||||||
assert opp.type == 'opportunity', 'Lead is not converted to opportunity!'
|
assert opp.type == 'opportunity', 'Lead is not converted to opportunity!'
|
||||||
assert opp.partner_id.name == "Thomas Passot", 'Partner mismatch!'
|
expected_partner = "Thomas Passot"
|
||||||
|
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!'
|
assert opp.stage_id.id == ref("stage_lead1"), 'Stage of probability is incorrect!'
|
||||||
-
|
-
|
||||||
Then check for second lead converted on opportunity.
|
Then check for second lead converted on opportunity.
|
||||||
|
|
|
@ -153,11 +153,24 @@ class crm_lead2opportunity_mass_convert(osv.osv_memory):
|
||||||
_description = 'Mass Lead To Opportunity Partner'
|
_description = 'Mass Lead To Opportunity Partner'
|
||||||
_inherit = 'crm.lead2opportunity.partner'
|
_inherit = 'crm.lead2opportunity.partner'
|
||||||
|
|
||||||
|
|
||||||
_columns = {
|
_columns = {
|
||||||
'user_ids': fields.many2many('res.users', string='Salesmen'),
|
'user_ids': fields.many2many('res.users', string='Salesmen'),
|
||||||
'section_id': fields.many2one('crm.case.section', 'Sales Team'),
|
'section_id': fields.many2one('crm.case.section', 'Sales Team'),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
def default_get(self, cr, uid, fields, context=None):
|
||||||
|
res = super(crm_lead2opportunity_mass_convert, self).default_get(cr, uid, fields, context)
|
||||||
|
if 'partner_id' in fields:
|
||||||
|
# avoid forcing the partner of the first lead as default
|
||||||
|
res['partner_id'] = False
|
||||||
|
if 'action' in fields:
|
||||||
|
res['action'] = 'create'
|
||||||
|
if 'name' in fields:
|
||||||
|
res['name'] = 'convert'
|
||||||
|
if 'opportunity_ids' in fields:
|
||||||
|
res['opportunity_ids'] = False
|
||||||
|
return res
|
||||||
|
|
||||||
def _convert_opportunity(self, cr, uid, ids, vals, context=None):
|
def _convert_opportunity(self, cr, uid, ids, vals, context=None):
|
||||||
data = self.browse(cr, uid, ids, context=context)[0]
|
data = self.browse(cr, uid, ids, context=context)[0]
|
||||||
salesteam_id = data.section_id and data.section_id.id or False
|
salesteam_id = data.section_id and data.section_id.id or False
|
||||||
|
|
Loading…
Reference in New Issue