[IMP+FIX] crm: clean test case, correct issues, added demo data of section for Sales Marketing Team, rename lead_form.yml with onchange_events.yml
bzr revid: hmo@tinyerp.com-20111025073957-e6m4fr70g6e29k0s
This commit is contained in:
parent
4dced583f6
commit
36061f54a3
|
@ -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,
|
||||
|
|
|
@ -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):
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<openerp>
|
||||
<data noupdate="1">
|
||||
<data>
|
||||
<record id="base.user_demo" model="res.users">
|
||||
<field name="groups_id" eval="[(4,ref('base.group_sale_salesman'))]"/>
|
||||
</record>
|
||||
|
@ -12,5 +12,11 @@
|
|||
<field name="res_id" ref="crm.menu_crm_case_categ_meet"/>
|
||||
</record>
|
||||
|
||||
<record model="crm.case.section" id="section_sales_marketing_department">
|
||||
<field name="name">Sales Marketing Department</field>
|
||||
<field name="code">Sales Marketing</field>
|
||||
<field name="parent_id" ref="crm.section_sales_department"></field>
|
||||
</record>
|
||||
|
||||
</data>
|
||||
</openerp>
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<?xml version="1.0"?>
|
||||
<openerp>
|
||||
<data noupdate="1">
|
||||
<data>
|
||||
<!-- Demo Leads -->
|
||||
<record id="crm_case_itisatelesalescampaign0" model="crm.lead">
|
||||
<field name="type_id" ref="crm.type_lead1"/>
|
||||
|
@ -9,7 +9,7 @@
|
|||
<field name="user_id" ref="base.user_root"/>
|
||||
<field eval="'The Oil Company'" name="partner_name"/>
|
||||
<field eval="'draft'" name="state"/>
|
||||
<field name="section_id" ref="crm.section_sales_department"/>
|
||||
<field name="section_id" ref="crm.section_sales_marketing_department"/>
|
||||
<field eval="'Luc Latour'" name="contact_name"/>
|
||||
<field name="title" ref="base.res_partner_title_sir"/>
|
||||
<field eval="'Training Manager'" name="function"/>
|
||||
|
@ -92,7 +92,7 @@
|
|||
<field eval="'Bruxelles'" name="city"/>
|
||||
<field name="country_id" ref="base.be"/>
|
||||
<field eval="'draft'" name="state"/>
|
||||
<field name="section_id" ref="crm.section_sales_department"/>
|
||||
<field name="section_id" ref="crm.section_sales_marketing_department"/>
|
||||
<field eval="'(333) 715-1450'" name="mobile"/>
|
||||
<field eval="1" name="active"/>
|
||||
<field name="categ_id" ref="crm.categ_oppor1"/>
|
||||
|
|
|
@ -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")])
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -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
|
||||
-
|
||||
|
|
|
@ -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)
|
||||
|
||||
|
|
|
@ -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"
|
||||
|
||||
|
|
|
@ -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"
|
||||
|
|
@ -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"))
|
||||
|
||||
|
||||
|
||||
|
|
@ -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:
|
||||
|
|
|
@ -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()
|
||||
|
||||
|
|
Loading…
Reference in New Issue