diff --git a/addons/crm/__openerp__.py b/addons/crm/__openerp__.py index 83b0354912a..23f84606c29 100644 --- a/addons/crm/__openerp__.py +++ b/addons/crm/__openerp__.py @@ -123,6 +123,7 @@ Creates a dashboard for CRM that includes: 'test/process/lead2opportunity2win.yml', 'test/process/merge_opportunity.yml', 'test/process/cancel_lead.yml', + 'test/process/action_rule.yml', 'test/process/segmentation.yml', 'test/ui/crm_demo.yml', 'test/ui/duplicate_lead.yml', diff --git a/addons/crm/crm_action_rule.py b/addons/crm/crm_action_rule.py index 3947eb58156..10ad262d38e 100644 --- a/addons/crm/crm_action_rule.py +++ b/addons/crm/crm_action_rule.py @@ -125,7 +125,7 @@ class base_action_rule(osv.osv): """Gets available states for crm""" res = super(base_action_rule, self).state_get(cr, uid, context=context) return res + crm.AVAILABLE_STATES - + # Dead Code def priority_get(self, cr, uid, context=None): res = super(base_action_rule, self).priority_get(cr, uid, context=context) return res + crm.AVAILABLE_PRIORITIES diff --git a/addons/crm/crm_phonecall.py b/addons/crm/crm_phonecall.py index b9bb6d359b1..4246fa43a98 100644 --- a/addons/crm/crm_phonecall.py +++ b/addons/crm/crm_phonecall.py @@ -118,7 +118,7 @@ class crm_phonecall(crm_base, osv.osv): """Resets case as Todo """ res = super(crm_phonecall, self).case_reset(cr, uid, ids, args, 'crm.phonecall') - self.write(cr, uid, ids, {'duration': 0.0}) + self.write(cr, uid, ids, {'duration': 0.0, 'state':'open'}) return res diff --git a/addons/crm/test/process/action_rule.yml b/addons/crm/test/process/action_rule.yml new file mode 100644 index 00000000000..f96c1eb7391 --- /dev/null +++ b/addons/crm/test/process/action_rule.yml @@ -0,0 +1,22 @@ +- + I create a record rule. +- + !python {model: base.action.rule}: | + modle_id = self.pool.get("ir.model").search(cr, uid, [('name', '=', 'crm.lead')]) + from datetime import datetime + new_id = self.create(cr, uid, {'name': 'New Rule', 'model_id': modle_id[0], 'trg_user_id': ref('base.user_root'), 'trg_partner_id': ref('base.res_partner_asus'), 'act_user_id': ref('base.user_demo') }) + lead_obj = self.pool.get("crm.lead") + self._check(cr, uid) +- + I create new lead to check record rule. +- + !record {model: crm.lead, id: crm_lead_test_rules_id}: + name: 'Test lead rules' + user_id: base.user_root + partner_id: base.res_partner_asus +- + I check record rule is apply and responsible is changed. +- + !python {model: crm.lead}: | + lead_user = self.browse(cr, uid, ref('crm_lead_test_rules_id')) + assert lead_user.user_id.id == ref('base.user_demo'), "Responsible of lead is not changed." diff --git a/addons/crm/test/process/cancel_lead.yml b/addons/crm/test/process/cancel_lead.yml index a5f85a14058..ca5f7d0174a 100644 --- a/addons/crm/test/process/cancel_lead.yml +++ b/addons/crm/test/process/cancel_lead.yml @@ -29,12 +29,12 @@ !assert {model: crm.lead, id: crm.crm_case_itisatelesalescampaign0, string: Lead is in pending state}: - state == "pending" - - I Escalate the Lead to Parent Team. + I escalate the lead to parent team. - !python {model: crm.lead}: | self.case_escalate(cr, uid, [ref("crm_case_itisatelesalescampaign0")]) - - I check lead escalate to Parent Team. + I check lead escalate to parent team. - !assert {model: crm.lead, id: crm.crm_case_itisatelesalescampaign0, string: Escalate lead to parent team}: - section_id.name == "Sales Department" diff --git a/addons/crm/test/process/communication_with_customer.yml b/addons/crm/test/process/communication_with_customer.yml index 92e711ce016..83d2ce915ac 100644 --- a/addons/crm/test/process/communication_with_customer.yml +++ b/addons/crm/test/process/communication_with_customer.yml @@ -1,5 +1,5 @@ - - Customer interested in our product. so He send request by email to get more details. + 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 - @@ -41,10 +41,12 @@ partner_ids = self.message_partner_by_email(cr, uid, 'Mr. John Right ') assert partner_ids.get('partner_id'), "Customer is not found in regular customer list." - - I convert one phonecall request as a customer and put into regular customer list. + I convert one phonecall request as a customer and put into regular customer list. - - !python {model: crm.phonecall}: | - self.convert_partner(cr, uid, [ref('crm.crm_case_phone06')], context=context) + !python {model: crm.phonecall2partner}: | + context.update({'active_model': 'crm.phonecall', 'active_ids': [ref("crm.crm_case_phone06")], 'active_id': ref("crm.crm_case_phone06")}) + new_id = self.create(cr, uid, {}, context=context) + self.make_partner(cr, uid, [new_id], context=context) - I check converted phonecall to partner. - diff --git a/addons/crm/test/process/lead2opportunity2win.yml b/addons/crm/test/process/lead2opportunity2win.yml index dbc04abae19..a5b6c421dbb 100644 --- a/addons/crm/test/process/lead2opportunity2win.yml +++ b/addons/crm/test/process/lead2opportunity2win.yml @@ -6,10 +6,18 @@ !python {model: crm.lead}: | self.case_open(cr, uid, [ref("crm_case_qrecorp0")]) - - I check lead state is "Open". + I check lead state is "Open". - !assert {model: crm.lead, id: crm.crm_case_qrecorp0, string: Lead in open state}: - state == "open" +- + I create partner from lead. +- + !record {model: crm.lead2partner, id: crm_lead2partner_id1, context: '{"active_model": "crm.lead", "active_ids": [ref("crm_case_qrecorp0")]}'}: +- + !python {model: crm.lead2partner}: | + context.update({'active_model': 'crm.lead', 'active_ids': [ref('crm_case_qrecorp0')], 'active_id': ref('crm_case_qrecorp0')}) + self.make_partner(cr, uid ,[ref("crm_lead2partner_id1")], context=context) - I convert lead into opportunity for exiting customer. - @@ -39,13 +47,13 @@ ids = self.search(cr, uid, [('opportunity_id', '=', ref('crm_case_qrecorp0'))]) assert len(ids), 'phonecall is not scheduled' - - Now I schedule Meeting with Customer. + 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. + After communicated with customer, I put some notes with contract details. - !python {model: crm.add.note}: | context.update({'active_model': 'crm.lead', 'active_id': ref('crm_case_qrecorp0')}) @@ -57,7 +65,7 @@ !python {model: crm.lead}: | self.case_mark_won(cr, uid, [ref("crm_case_qrecorp0")]) - - I check details of the opportunity After won the opportunity. + I check details of the opportunity after won the opportunity. - !python {model: crm.lead}: | lead = self.browse(cr, uid, ref('crm_case_qrecorp0')) @@ -72,7 +80,7 @@ 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) - - Now I check First lead converted on opportunity. + Now I check first lead converted on opportunity. - !python {model: crm.lead}: | opp = self.browse(cr, uid, ref('crm_case_employee0')) @@ -81,10 +89,22 @@ assert opp.partner_id.name == "Agrolait", 'Partner missmatch!' 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. - !python {model: crm.lead}: | opp = self.browse(cr, uid, ref('crm_case_electonicgoodsdealer0')) assert opp.name == "Interest in Your New Product", "Opportunity name not correct" assert opp.type == 'opportunity', 'Lead is not converted to opportunity!' - assert opp.stage_id.id == ref("stage_lead1"), 'Stage of probability is incorrect!' \ No newline at end of file + assert opp.stage_id.id == ref("stage_lead1"), 'Stage of probability is incorrect!' +- + I confirm review needs meeting. +- + !python {model: crm.meeting}: | + context.update({'active_model': 'crm.meeting'}) + self.case_open(cr, uid, [ref('crm.crm_case_reviewneeds0')]) +- + I invite a user for meeting. +- + !python {model: calendar.attendee}: | + meeting_id = self.create(cr, uid, {'user_id': ref('base.user_root'), 'email': 'user@meeting.com' }) + self.do_accept(cr, uid, [meeting_id]) diff --git a/addons/crm/test/process/merge_opportunity.yml b/addons/crm/test/process/merge_opportunity.yml index 463e330fc10..c4e939f194e 100644 --- a/addons/crm/test/process/merge_opportunity.yml +++ b/addons/crm/test/process/merge_opportunity.yml @@ -1,5 +1,5 @@ - - I make direct opportunity for Customer. + I make direct opportunity for customer. - !python {model: crm.partner2opportunity}: | context.update({'active_model': 'res.partner', 'active_ids': [ref("base.res_partner_9")]}) @@ -13,13 +13,18 @@ res_id = self.create(cr, uid, {'name': "Quoi de prix de votre autre service?", 'partner_id': ref("base.res_partner_9")}, context=context) self.make_opportunity(cr, uid, [res_id], context=context) - - Now I merge all opportunities of customer. + Now I merge all opportunities of customer. - !python {model: crm.lead}: | opportunity_ids = self.search(cr, uid, [('partner_id','=', ref("base.res_partner_9"))]) - self.merge_opportunity(cr, uid, opportunity_ids, context=context) + context.update({'active_model': 'crm.lead', 'active_ids': opportunity_ids, 'active_id': opportunity_ids[0]}) - - I check for merged opportunities for customer. + !record {model: crm.merge.opportunity, id: opportunity_merge_id }: +- + !python {model: crm.merge.opportunity}: | + self.action_merge(cr, uid, [ref("opportunity_merge_id")], context=context) +- + I check for merged opportunities for customer. - !python {model: crm.lead}: | merge_id = self.search(cr, uid, [('partner_id','=', ref("base.res_partner_9"))]) @@ -31,21 +36,51 @@ Now I schedule another phonecall to customer after merged. - !python {model: crm.phonecall2phonecall}: | - context.update({'active_model': 'crm.phonecall', 'active_ids': [ref("crm.crm_case_phone06")]}) + context.update({'active_model': 'crm.phonecall', 'active_ids': [ref("crm.crm_case_phone06")], 'active_id': ref("crm.crm_case_phone06")}) 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. + 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). + I set phone call to not held. +- + !python {model: crm.phonecall}: | + self.case_pending(cr, uid, [ref("crm.crm_case_phone06")]) +- + I check that the phone call is in 'Not Held' state. +- + !assert {model: crm.phonecall, id: crm.crm_case_phone06, string: Phone call held.}: + - state == "pending" +- + I cancelled the phone call. +- + !python {model: crm.phonecall}: | + self.case_cancel(cr, uid, [ref("crm.crm_case_phone06")]) +- + I check that the phone call is in 'Cancelled' state. +- + !assert {model: crm.phonecall, id: crm.crm_case_phone06, string: Phone call is not cancelled.}: + - state == "cancel" +- + I reset the phone call. +- + !python {model: crm.phonecall}: | + self.case_reset(cr, uid, [ref("crm.crm_case_phone06")]) +- + I check that the phone call is reset or not. +- + !assert {model: crm.phonecall, id: crm.crm_case_phone06, string: Phone call is not reset.}: + - state == "open" +- + I set phone call to held (done). - !python {model: crm.phonecall}: | self.case_close(cr, uid, [ref("crm.crm_case_phone06")]) - I check that the phone call is in 'Held' state. - - !assert {model: crm.phonecall, id: crm.crm_case_phone06, string: Phone call Helded}: + !assert {model: crm.phonecall, id: crm.crm_case_phone06, string: Phone call is not held.}: - state == "done" diff --git a/addons/crm/test/process/segmentation.yml b/addons/crm/test/process/segmentation.yml index 74500049290..f3801b80ec6 100644 --- a/addons/crm/test/process/segmentation.yml +++ b/addons/crm/test/process/segmentation.yml @@ -8,7 +8,7 @@ #Todo: Need to check after segmentation started - - I create rule Segmentation line record for partner . + I create rule segmentation line record for partner . - !python {model: crm.segmentation.line}: | id = self.create(cr, uid, {'name': "OpenERP partners",'expr_value': 25})