diff --git a/addons/crm/__openerp__.py b/addons/crm/__openerp__.py index 8e195bb5d01..dd22590ee84 100644 --- a/addons/crm/__openerp__.py +++ b/addons/crm/__openerp__.py @@ -123,7 +123,7 @@ Creates a dashboard for CRM that includes: 'test/process/lead2opportunity2win.yml', 'test/process/merge_opportunity.yml', 'test/process/cancel_lead.yml', - 'test/ui/lead_form.yml', + 'test/ui/onchange_events.yml', ], 'installable': True, 'active': False, diff --git a/addons/crm/crm.py b/addons/crm/crm.py index ac0874a6037..d192ddeca43 100644 --- a/addons/crm/crm.py +++ b/addons/crm/crm.py @@ -467,10 +467,12 @@ class crm_case(crm_base): self._action(cr, uid, cases, state) return True + #DEAD Code def remind_partner(self, cr, uid, ids, context=None, attach=False): return self.remind_user(cr, uid, ids, context, attach, destination=False) + #DEAD Code def remind_user(self, cr, uid, ids, context=None, attach=False, destination=True): mail_message = self.pool.get('mail.message') for case in self.browse(cr, uid, ids, context=context): diff --git a/addons/crm/crm_demo.xml b/addons/crm/crm_demo.xml index 16ae0e73129..08d09904c06 100644 --- a/addons/crm/crm_demo.xml +++ b/addons/crm/crm_demo.xml @@ -1,6 +1,6 @@ - + @@ -12,5 +12,11 @@ + + Sales Marketing Department + Sales Marketing + + + diff --git a/addons/crm/crm_lead_demo.xml b/addons/crm/crm_lead_demo.xml index 390932c9e0a..9073abb6a00 100644 --- a/addons/crm/crm_lead_demo.xml +++ b/addons/crm/crm_lead_demo.xml @@ -1,6 +1,6 @@ - + @@ -9,7 +9,7 @@ - + @@ -92,7 +92,7 @@ - + diff --git a/addons/crm/test/process/cancel_lead.yml b/addons/crm/test/process/cancel_lead.yml index 0cc13208d03..6b08136c086 100644 --- a/addons/crm/test/process/cancel_lead.yml +++ b/addons/crm/test/process/cancel_lead.yml @@ -28,4 +28,17 @@ - !assert {model: crm.lead, id: crm.crm_case_itisatelesalescampaign0, string: Lead is in pending state}: - state == "pending" +- + I Escalate the Lead to Parent Team. +- + !python {model: crm.lead}: | + self.case_escalate(cr, uid, [ref("crm_case_itisatelesalescampaign0")]) + +- + I mark as lost the Lead. +- + !python {model: crm.lead}: | + self.case_mark_won(cr, uid, [ref("crm_case_itisatelesalescampaign0")]) + + diff --git a/addons/crm/test/process/communication_with_customer.yml b/addons/crm/test/process/communication_with_customer.yml index 444c7a704d2..56a0e8acde1 100644 --- a/addons/crm/test/process/communication_with_customer.yml +++ b/addons/crm/test/process/communication_with_customer.yml @@ -1,5 +1,5 @@ - - Customer would like to purchase our product. so He send request by email to our mail server. + Customer interested in our product. so He send request by email to get more details. - Mail script will be fetched him request from mail server. so I process that mail after read EML file - diff --git a/addons/crm/test/process/lead2opportunity2win.yml b/addons/crm/test/process/lead2opportunity2win.yml index ed33a251b80..c5f2afd676d 100644 --- a/addons/crm/test/process/lead2opportunity2win.yml +++ b/addons/crm/test/process/lead2opportunity2win.yml @@ -1,10 +1,12 @@ +- + In order to test convert customer lead into opportunity, - I open customer lead. - !python {model: crm.lead}: | self.case_open(cr, uid, [ref("crm_case_qrecorp0")]) - - I check lead is in open stage. + I check lead is in open. - !assert {model: crm.lead, id: crm.crm_case_qrecorp0, string: Lead in open state}: - state == "open" @@ -23,7 +25,7 @@ assert lead.partner_id.id == ref("base.res_partner_agrolait"), 'Partner missmatch!' assert lead.stage_id.id == ref("stage_lead1"), 'Stage of opportunity is incorrect!' - - Now I start Communication by phonecall with customer. + Now I start Communication and schedule phonecall with customer. - !python {model: crm.opportunity2phonecall}: | import time @@ -31,6 +33,19 @@ call_id = self.create(cr, uid, {'date': time.strftime('%Y-%m-%d %H:%M:%S'), 'name': "Bonjour M. Jean, Comment ĂȘtes-vous? J'ai obtenu votre demande. peut-on parler au sujet de ce pour quelques minutes?"}, context=context) self.action_schedule(cr, uid, [call_id], context=context) +- + I check that phonecall is scheduled for that opportunity. +- + !python {model: crm.phonecall}: | + ids = self.search(cr, uid, [('opportunity_id', '=', ref('crm_case_qrecorp0'))]) + assert len(ids), 'phonecall is not scheduled' + +- + Now I schedule Meeting with Customer. +- + !python {model: crm.lead}: | + self.action_makeMeeting(cr, uid, [ref('crm_case_qrecorp0')]) + - After communicated with customer, I put some notes with Contract details. - @@ -51,3 +66,12 @@ assert lead.state == 'done', 'Opportunity is not in done state!' assert lead.stage_id.name == 'Won', ' Stage of Opportunity is not win!' assert lead.probability == 100.0, 'probability revenue should not be 100.0!' + +- + I convert mass lead into opportunity customer. +- + !python {model: crm.lead2opportunity.partner.mass}: | + context.update({'active_model': 'crm.lead', 'active_ids': [ref('crm_case_itdeveloper0')]}) + 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) + diff --git a/addons/crm/test/process/merge_opportunity.yml b/addons/crm/test/process/merge_opportunity.yml index 6d16ca17694..2c3ad010255 100644 --- a/addons/crm/test/process/merge_opportunity.yml +++ b/addons/crm/test/process/merge_opportunity.yml @@ -28,3 +28,20 @@ res_id = self.create(cr, uid, {'name': "vos chances sont fusionnĂ©s en un seul"}, context=context) self.action_schedule(cr, uid, [res_id], context=context) +- + I schedule Meeting on this phonecall. +- + !python {model: crm.phonecall}: | + self.action_make_meeting(cr, uid, [ref("crm.crm_case_phone06")]) + +- + I setting Phone call to Held (Done). +- + !python {model: crm.phonecall}: | + self.case_close(cr, uid, [ref("crm.crm_case_phone06")]) +- + I check that the hone call is in 'Held' state. +- + !assert {model: crm.phonecall, id: crm.crm_case_phone06, string: Phone call Helded}: + - state == "done" + diff --git a/addons/crm/test/ui/lead_form.yml b/addons/crm/test/ui/lead_form.yml deleted file mode 100644 index 7ec86106947..00000000000 --- a/addons/crm/test/ui/lead_form.yml +++ /dev/null @@ -1,8 +0,0 @@ -- - I check onchange event of partner address on lead form. -- - !python {model: crm.lead}: | - action = self.onchange_partner_address_id(cr, uid, ref("crm_case_qrecorp0"), ref("base.res_partner_address_notsotinysarl0"), email=False) - assert action['value']['country_id'] == 20, "Country name not True" - assert action['value']['phone'] == '(+32).81.81.37.00', "phone number is wrong" - diff --git a/addons/crm/test/ui/onchange_events.yml b/addons/crm/test/ui/onchange_events.yml new file mode 100644 index 00000000000..4f067ab0a57 --- /dev/null +++ b/addons/crm/test/ui/onchange_events.yml @@ -0,0 +1,51 @@ +- + I call onchange event to change partner address for lead. +- + !python {model: crm.lead}: | + action = self.onchange_partner_address_id(cr, uid, ref("crm_case_qrecorp0"), ref("base.res_partner_address_notsotinysarl0"), email=False) + assert action['value']['country_id'] == 20, "Country name not True" + assert action['value']['phone'] == '(+32).81.81.37.00', "phone number is wrong" +- + I call onchange event to change email "Opt-out" option for Lead. +- + !python {model: crm.lead}: | + self.on_change_optout(cr, uid, ref("crm_case_qrecorp0"), True) + +- + I call onchange event to convert the Opt-out to Opt-in to show email receive preference for lead. +- + !python {model: crm.lead}: | + self.on_change_optin(cr, uid, ref("crm_case_qrecorp0"), True) + +- + I setting next stage "New" for the lead. +- + !python {model: crm.lead}: | + self.stage_next(cr, uid, [ref("crm_case_qrecorp0")], context={'stage_type': 'lead'}) +- + I call onchange event to assigning won stage for Lead. +- + !python {model: crm.lead}: | + stage_id = self.stage_find_won(cr, uid, ref('crm.section_sales_department')) + self.onchange_stage_id(cr, uid, [ref("crm_case_qrecorp0")], stage_id, context) +- + I make duplicate the Lead. +- + !python {model: crm.lead}: | + self.copy(cr, uid, ref("crm_case_qrecorp0")) + +- + I Unlink the Lead. +- + !python {model: crm.lead}: | + self.unlink(cr, uid, [ref("crm_case_qrecorp0")]) + +- + I call onchange event to change Contact Detail for Phonecall. +- + !python {model: crm.phonecall}: | + self.onchange_partner_address_id(cr, uid,[ref("crm.crm_case_phone06")], ref("base.res_partner_address_8invoice")) + + + + diff --git a/addons/crm/wizard/crm_lead_to_opportunity.py b/addons/crm/wizard/crm_lead_to_opportunity.py index 9b03f7813a1..9a828668944 100644 --- a/addons/crm/wizard/crm_lead_to_opportunity.py +++ b/addons/crm/wizard/crm_lead_to_opportunity.py @@ -102,15 +102,14 @@ class crm_lead2opportunity_partner(osv.osv_memory): raise osv.except_osv(_("Warning !"), _("Closed/Cancelled Leads can not be converted into Opportunity")) return False - def _convert_opportunity(self, cr, uid, ids, context=None): + def _convert_opportunity(self, cr, uid, ids, vals, context=None): if context is None: context = {} lead = self.pool.get('crm.lead') - partner_ids = self._create_partner(cr, uid, ids, context=context) - partner_id = partner_ids and partner_ids[0] or False - lead_ids = context.get('active_ids', []) - user_ids = context.get('user_ids', False) - team_id = context.get('section_id', False) + partner_id = self._create_partner(cr, uid, ids, context=context) + lead_ids = vals.get('lead_ids', []) + user_ids = vals.get('user_ids', False) + team_id = vals.get('section_id', False) return lead.convert_opportunity(cr, uid, lead_ids, partner_id, user_ids, team_id, context=context) def _merge_opportunity(self, cr, uid, ids, opportunity_ids, action='merge', context=None): @@ -129,18 +128,15 @@ class crm_lead2opportunity_partner(osv.osv_memory): def action_apply(self, cr, uid, ids, context=None): """ This converts lead to opportunity and opens Opportunity view - @param ids: ids of the leads to convert to opportunities - - @return : View dictionary opening the Opportunity form view """ if not context: context = {} lead = self.pool.get('crm.lead') + lead_ids = context.get('active_ids', []) data = self.browse(cr, uid, ids, context=context)[0] - self._convert_opportunity(cr, uid, ids, context=context) + self._convert_opportunity(cr, uid, ids, {'lead_ids': lead_ids}, context=context) self._merge_opportunity(cr, uid, ids, data.opportunity_ids, data.action, context=context) - return lead.redirect_opportunity_view(cr, uid, lead_ids[0], context=context) crm_lead2opportunity_partner() @@ -156,24 +152,19 @@ class crm_lead2opportunity_mass_convert(osv.osv_memory): 'section_id': fields.many2one('crm.case.section', 'Sales Team'), } - - def mass_convert(self, cr, uid, ids, context=None): - lead = self.pool.get('crm.lead') - if not context: - context = {} - - active_ids = context.get('active_ids') + def _convert_opportunity(self, cr, uid, ids, vals, context=None): data = self.browse(cr, uid, ids, context=context)[0] - salesteam_id = data.section_id and data.section_id.id or False salesman = [] if data.user_ids: salesman = [x.id for x in data.user_ids] - + vals.update({'user_ids': salesman, 'section_id': salesteam_id}) + return super(crm_lead2opportunity_mass_convert, self)._convert_opportunity(cr, uid, ids, vals, context=context) + + def mass_convert(self, cr, uid, ids, context=None): value = self.default_get(cr, uid, ['partner_id', 'opportunity_ids'], context=context) value['opportunity_ids'] = [(6, 0, value['opportunity_ids'])] self.write(cr, uid, ids, value, context=context) - context.update({'user_ids': salesman, 'section_id': salesteam_id}) return self.action_apply(cr, uid, ids, context=context) crm_lead2opportunity_mass_convert() # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/crm/wizard/crm_lead_to_partner.py b/addons/crm/wizard/crm_lead_to_partner.py index 5363264ca37..c424d511639 100644 --- a/addons/crm/wizard/crm_lead_to_partner.py +++ b/addons/crm/wizard/crm_lead_to_partner.py @@ -105,17 +105,17 @@ class crm_lead2partner(osv.osv_memory): context = {} lead = self.pool.get('crm.lead') lead_ids = context and context.get('active_ids') or [] - for data in self.browse(cr, uid, ids, context=context): - partner_id = data.partner_id and data.partner_id.id or False - partner_ids += lead.convert_partner(cr, uid, lead_ids, data.action, partner_id, context=context) - return partner_ids + data = self.browse(cr, uid, ids, context=context)[0] + partner_id = data.partner_id and data.partner_id.id or False + partner_ids = lead.convert_partner(cr, uid, lead_ids, data.action, partner_id, context=context) + return partner_ids[lead_ids[0]] def make_partner(self, cr, uid, ids, context=None): """ This function Makes partner based on action. """ - partner_ids = self._create_partner(cr, uid, ids, context=context) - return self.pool.get('res.partner').redirect_partner_form(cr, uid, partner_ids[0], context=context) + partner_id = self._create_partner(cr, uid, ids, context=context) + return self.pool.get('res.partner').redirect_partner_form(cr, uid, partner_id, context=context) crm_lead2partner()