odoo/addons/crm/test/test_crm_stage_changes.yml

97 lines
3.0 KiB
YAML

-
In order to test the changes on stage of a lead or an opportunity with OpenERP,
I create some leads and test the stage changes.
-
I want to change the probability to 0.0 when the opportunity is marked as lost.
So I set its Change probability automatically true.
-
!record {model: crm.case.stage, id: crm.stage_lead6}:
name: Lost
on_change: true
probability: 0.0
section_ids:
- crm.section_sales_department
sequence: 0
-
I create a lead 'Test Lead1'.
-
!record {model: crm.lead, id: crm_lead_openerppresentation0}:
categ_id: crm.categ_oppor4
day_close: 0.0
day_open: 0.0
name: Test Lead1
planned_revenue: 0.0
probability: 10.0
section_id: crm.section_sales_department
-
I open the lead.
-
!python {model: crm.lead}: |
self.case_open(cr, uid, [ref('crm_lead_openerppresentation0')])
-
I assigning stage.
-
!python {model: crm.lead}: |
self.onchange_stage_id(cr, uid, [ref('crm_lead_openerppresentation0')], [], context)
-
I assigning percent.
-
!python {model: crm.lead}: |
self.stage_find_percent(cr, uid, 10.0, [])
-
I find that this lead can be converted to opportunity.
-
!record {model: crm.lead2opportunity.partner, id: crm_lead2opportunity_partner0}:
action: 'create'
name: 'convert'
-
So I convert the lead to opportunity.
-
!python {model: crm.lead2opportunity.partner}: |
self.action_apply(cr, uid, [ref('crm_lead2opportunity_partner0')], context={'active_ids': [ref('crm_lead_openerppresentation0')]})
-
I check that lead is now converted to opportunity.
-
!python {model: crm.lead}: |
lead = self.browse(cr, uid, ref('crm_lead_openerppresentation0'))
assert lead.type == 'opportunity', 'Lead is not converted to opportunity!'
-
I mark this opportunity as lost.
-
!python {model: crm.lead}: |
self.case_mark_lost(cr, uid, [ref('crm_lead_openerppresentation0')])
-
I check whether the probability is set according to stage change or not.
-
!python {model: crm.lead}: |
opportunity = self.browse(cr, uid, ref('crm_lead_openerppresentation0'))
assert opportunity.stage_id.id == ref('crm.stage_lead6'), 'Stage is not changed!'
assert opportunity.probability == 0.0, 'Probability is wrong!'
-
I create one more opportunity.
-
!record {model: crm.lead, id: crm_lead_test2}:
name: Partner Demo
type: opportunity
categ_id: crm.categ_oppor3
planned_revenue: 50000.0
probability: 100.0
section_id: crm.section_sales_department
-
I open this opportunity.
-
!python {model: crm.lead}: |
self.case_open(cr, uid, [ref('crm_lead_test2')])
-
I mark this opportunity as won.
-
!python {model: crm.lead}: |
self.case_mark_won(cr, uid, [ref('crm_lead_test2')])
-
I check whether the stage is changed to 'Won' and probability is 100.0 or not.
-
!python {model: crm.lead}: |
opportunity = self.browse(cr, uid, ref('crm_lead_test2'))
assert opportunity.stage_id.id == ref('crm.stage_lead5'), 'Stage is not changed!'
assert opportunity.probability == 100.0, 'Probability is wrong!'