diff --git a/addons/crm/crm.py b/addons/crm/crm.py
index 9798fd09a4e..c3a4ef44a9c 100644
--- a/addons/crm/crm.py
+++ b/addons/crm/crm.py
@@ -146,11 +146,12 @@ class crm_case(object):
if not context:
context = {}
stage_pool = self.pool.get('crm.case.stage')
- model = self._name
+ stage_type = context and context.get('stage_type','')
+ current_seq = False
for case in self.browse(cr, uid, ids, context):
next_stage = False
data = {}
- domain = [('object_id.model', '=', model),('section_ids', '=', case.section_id.id)]
+ domain = [('type', '=', stage_type),('section_ids', '=', case.section_id.id)]
if case.section_id and case.section_id.stage_ids:
domain.append(('id', 'in', map(lambda x: x.id, case.section_id.stage_ids)))
stages = stage_pool.search(cr, uid, domain, order='sequence')
@@ -161,9 +162,12 @@ class crm_case(object):
return False
else:
next_stage = stages[index + 1]
+ current_seq = case.stage_id.sequence
if next_stage:
- data = {'stage_id': next_stage}
stage = stage_pool.browse(cr, uid, next_stage, context=context)
+ next_seq = stage.sequence
+ if current_seq and (next_seq - current_seq) >= 1:
+ data = {'stage_id': next_stage}
if stage.on_change:
data.update({'probability': stage.probability})
self.write(cr, uid, [case.id], data, context=context)
@@ -180,11 +184,11 @@ class crm_case(object):
if not context:
context = {}
stage_pool = self.pool.get('crm.case.stage')
- model = self._name
+ stage_type = context and context.get('stage_type','')
for case in self.browse(cr, uid, ids, context):
prev_stage = False
data = {}
- domain = [('object_id.model', '=', model),('section_ids', '=', case.section_id.id)]
+ domain = [('type', '=', stage_type),('section_ids', '=', case.section_id.id)]
if case.section_id and case.section_id.stage_ids:
domain.append(('id', 'in', map(lambda x: x.id, case.section_id.stage_ids)))
stages = stage_pool.search(cr, uid, domain, order='sequence')
@@ -195,9 +199,12 @@ class crm_case(object):
return False
else:
prev_stage = stages[index - 1]
+ current_seq = case.stage_id.sequence
if prev_stage:
- data = {'stage_id': prev_stage}
stage = stage_pool.browse(cr, uid, prev_stage, context=context)
+ prev_seq = stage.sequence
+ if current_seq and (prev_seq - current_seq) <= 1:
+ data = {'stage_id': prev_stage}
if stage.on_change:
data.update({'probability': stage.probability})
self.write(cr, uid, [case.id], data, context=context)
@@ -482,27 +489,27 @@ class crm_case_stage(osv.osv):
_columns = {
'name': fields.char('Stage Name', size=64, required=True, translate=True),
'sequence': fields.integer('Sequence', help="Gives the sequence order when displaying a list of case stages."),
- 'object_id': fields.many2one('ir.model', 'Object Name'),
'probability': fields.float('Probability (%)', required=True, help="This percentage depicts the default/average probability of the Case for this stage to be a success"),
'on_change': fields.boolean('Change Probability Automatically', \
help="Change Probability on next and previous stages."),
- 'requirements': fields.text('Requirements')
+ 'requirements': fields.text('Requirements'),
+ 'type': fields.selection([('lead','Lead'),('opportunity','Opportunity'),('claim','Claim'), ('fundraising','Fundraising')], 'Type'),
}
- def _find_object_id(self, cr, uid, context=None):
- """Finds id for case object
+
+ def _find_stage_type(self, cr, uid, context=None):
+ """Finds type of stage according to object.
@param self: The object pointer
@param cr: the current row, from the database cursor,
@param uid: the current user’s ID for security checks,
@param context: A standard dictionary for contextual values
"""
- object_id = context and context.get('object_id', False) or False
- ids = self.pool.get('ir.model').search(cr, uid, [('model', '=', object_id)])
- return ids and ids[0]
+ type = context and context.get('type', '') or ''
+ return type
_defaults = {
'sequence': lambda *args: 1,
'probability': lambda *args: 0.0,
- 'object_id' : _find_object_id
+ 'type': _find_stage_type,
}
crm_case_stage()
diff --git a/addons/crm/crm_lead.py b/addons/crm/crm_lead.py
index e0bed8934f2..8cc45c75e57 100644
--- a/addons/crm/crm_lead.py
+++ b/addons/crm/crm_lead.py
@@ -135,7 +135,7 @@ class crm_lead(crm_case, osv.osv):
],'Type', help="Type is used to separate Leads and Opportunities"),
'priority': fields.selection(crm.AVAILABLE_PRIORITIES, 'Priority'),
'date_closed': fields.datetime('Closed', readonly=True),
- 'stage_id': fields.many2one('crm.case.stage', 'Stage'),
+ 'stage_id': fields.many2one('crm.case.stage', 'Stage', domain="[('type','=','lead')]"),
'user_id': fields.many2one('res.users', 'Salesman',help='By Default Salesman is Administrator when create New User'),
'referred': fields.char('Referred By', size=64),
'date_open': fields.datetime('Opened', readonly=True),
@@ -150,6 +150,19 @@ class crm_lead(crm_case, osv.osv):
\nIf the case needs to be reviewed then the state is set to \'Pending\'.'),
'message_ids': fields.one2many('mailgate.message', 'res_id', 'Messages', domain=[('model','=',_name)]),
}
+
+ def _get_stage_id(self, cr, uid, context=None):
+ """Finds type of stage according to object.
+ @param self: The object pointer
+ @param cr: the current row, from the database cursor,
+ @param uid: the current user’s ID for security checks,
+ @param context: A standard dictionary for contextual values
+ """
+ if context is None:
+ context = {}
+ type = context and context.get('stage_type', '')
+ stage_ids = self.pool.get('crm.case.stage').search(cr, uid, [('type','=',type),('sequence','>=',1)])
+ return stage_ids and stage_ids[0] or False
_defaults = {
'active': lambda *a: 1,
@@ -160,6 +173,7 @@ class crm_lead(crm_case, osv.osv):
'section_id': crm_case._get_section,
'company_id': lambda s, cr, uid, c: s.pool.get('res.company')._company_default_get(cr, uid, 'crm.lead', context=c),
'priority': lambda *a: crm.AVAILABLE_PRIORITIES[2][0],
+ 'stage_id': _get_stage_id,
}
def onchange_partner_address_id(self, cr, uid, ids, add, email=False):
@@ -297,7 +311,7 @@ class crm_lead(crm_case, osv.osv):
return super(crm_lead,self).write(cr, uid, ids, vals, context)
def stage_next(self, cr, uid, ids, context=None):
- stage = super(crm_lead, self).stage_next(cr, uid, ids, context)
+ stage = super(crm_lead, self).stage_next(cr, uid, ids, context=context)
if stage:
stage_obj = self.pool.get('crm.case.stage').browse(cr, uid, stage, context=context)
if stage_obj.on_change:
diff --git a/addons/crm/crm_lead_data.xml b/addons/crm/crm_lead_data.xml
index 2a49e43e683..f10ba72ef8e 100644
--- a/addons/crm/crm_lead_data.xml
+++ b/addons/crm/crm_lead_data.xml
@@ -8,28 +8,28 @@
New
-
+ leadQualification
-
+ leadProposition
-
+ leadNegotiation
-
+ lead
@@ -37,14 +37,14 @@
-
+ leadLost
-
+ lead
diff --git a/addons/crm/crm_lead_menu.xml b/addons/crm/crm_lead_menu.xml
index 6c74dccac15..2fff1b57d3c 100644
--- a/addons/crm/crm_lead_menu.xml
+++ b/addons/crm/crm_lead_menu.xml
@@ -9,7 +9,7 @@
['|', ('type','=','lead'), ('type','=',False)]
- {'search_default_current':1, 'default_type': 'lead', 'search_default_section_id': section_id}
+ {'search_default_current':1, 'default_type': 'lead', 'search_default_section_id': section_id, 'stage_type': 'lead'}'Leads' allows you to manage and keep track of all first potential interests of a partner in one of your products or services. A lead is a first, unqualified, contact with a prospect or customer. After being qualified, a lead can be converted into a business opportunity with the creation of the related partner for further detailed tracking of any linked activities. You can use leads when you import a database of prospects or to integrate your website's contact form with OpenERP.
diff --git a/addons/crm/crm_lead_view.xml b/addons/crm/crm_lead_view.xml
index cda3c4fcc1f..87eb7ff3bd1 100644
--- a/addons/crm/crm_lead_view.xml
+++ b/addons/crm/crm_lead_view.xml
@@ -9,8 +9,8 @@
crm.case.stageform
- [('object_id.model', '=', 'crm.lead')]
- {'object_id':'crm.lead'}
+ [('type', '=', 'lead')]
+ {'type':'lead'}Create specific stages that will help your sales better organise their sales pipeline by maintaining them to their leads and sales opportunities. It will allow them to easily track how is positioned a specific lead or opportunity in the sales cycle.
@@ -57,11 +57,11 @@
-
+
+ icon="gtk-go-back" context="{'stage_type': 'lead'}"/>
@@ -329,7 +329,7 @@
-
+
diff --git a/addons/crm/crm_meeting_view.xml b/addons/crm/crm_meeting_view.xml
index 2f215488c99..2de562a23ce 100644
--- a/addons/crm/crm_meeting_view.xml
+++ b/addons/crm/crm_meeting_view.xml
@@ -47,7 +47,7 @@
diff --git a/addons/crm/crm_opportunity.py b/addons/crm/crm_opportunity.py
index b41621b6f00..44f2b1b85a4 100644
--- a/addons/crm/crm_opportunity.py
+++ b/addons/crm/crm_opportunity.py
@@ -50,7 +50,9 @@ class crm_opportunity(osv.osv):
'date_deadline': fields.date('Expected Closing'),
'date_action': fields.date('Next Action Date'),
'title_action': fields.char('Next Action', size=64),
+ 'stage_id': fields.many2one('crm.case.stage', 'Stage', domain="[('type','=','opportunity')]"),
}
+
def case_close(self, cr, uid, ids, *args):
"""Overrides close for crm_case for setting probability and close date
@param self: The object pointer
@@ -100,7 +102,7 @@ class crm_opportunity(osv.osv):
message = _("The opportunity '%s' has been marked as lost.") % name
self.log(cr, uid, id, message)
return res
-
+
def case_cancel(self, cr, uid, ids, *args):
"""Overrides cancel for crm_case for setting probability
@param self: The object pointer
diff --git a/addons/crm/crm_opportunity_data.xml b/addons/crm/crm_opportunity_data.xml
index c2f750c29d1..a20cbc5e344 100644
--- a/addons/crm/crm_opportunity_data.xml
+++ b/addons/crm/crm_opportunity_data.xml
@@ -1,56 +1,109 @@
-
- Interest in Computer
-
-
-
-
- Interest in Accessories
-
-
-
-
- Need Services
-
-
-
-
- Need Information
-
-
-
-
- Need a Website Design
-
-
-
-
- Potential Reseller
-
-
-
-
- Need Consulting
-
-
-
-
- Other
-
-
-
+
+
+
+
+ Lost
+
+
+ opportunity
+
+
+
+ New
+
+
+ opportunity
+
+
+
+ Qualification
+
+
+ opportunity
+
+
+
+ Proposition
+
+
+ opportunity
+
+
+
+ Negotiation
+
+
+ opportunity
+
+
+
+ Won
+
+
+
+ opportunity
+
+
+
+ Sales Department
+ Sales
+
+
+
+
+
+ Interest in Computer
+
+
+
+
+ Interest in Accessories
+
+
+
+
+ Need Services
+
+
+
+
+ Need Information
+
+
+
+
+ Need a Website Design
+
+
+
+
+ Potential Reseller
+
+
+
+
+ Need Consulting
+
+
+
+
+ Other
+
+
+
-
- Campaign 2
-
-
-
- Campaign 1
-
-
+
+ Campaign 2
+
+
+
+ Campaign 1
+
+
diff --git a/addons/crm/crm_opportunity_demo.xml b/addons/crm/crm_opportunity_demo.xml
index 48812b17cf0..8dda7436b64 100644
--- a/addons/crm/crm_opportunity_demo.xml
+++ b/addons/crm/crm_opportunity_demo.xml
@@ -20,7 +20,7 @@
-
+
@@ -36,7 +36,7 @@
-
+
@@ -53,7 +53,7 @@
-
+
@@ -70,7 +70,7 @@
-
+
@@ -86,7 +86,7 @@
-
+
diff --git a/addons/crm/crm_opportunity_menu.xml b/addons/crm/crm_opportunity_menu.xml
index 6b2e2d0fc39..cd57c2026af 100644
--- a/addons/crm/crm_opportunity_menu.xml
+++ b/addons/crm/crm_opportunity_menu.xml
@@ -28,7 +28,7 @@
crm.leadtree,form,graph,calendar[('type','=','opportunity')]
- {'search_default_user_id':uid,'search_default_current':1, 'search_default_section_id':section_id,'default_type': 'opportunity'}
+ {'search_default_user_id':uid,'search_default_current':1, 'search_default_section_id':section_id, 'stage_type': 'opportunity'}Opportunities allows you to manage and keep track of your sales pipeline by creating specific customer or prospect related sales documents in order to follow up potential sales. Information such as the expected revenue, opportunity stage, expected closing date, communication history and so on can be maintained in them. Opportunities can be connected with the email gateway: new emails create opportunities, each of them automatically gets the history of the conversation with the customer.
diff --git a/addons/crm/crm_opportunity_view.xml b/addons/crm/crm_opportunity_view.xml
index 5ca69c22790..c928b120579 100644
--- a/addons/crm/crm_opportunity_view.xml
+++ b/addons/crm/crm_opportunity_view.xml
@@ -1,6 +1,21 @@
+
+
+ Stages
+ crm.case.stage
+ form
+
+ [('type', '=', 'opportunity')]
+ {'type':'opportunity'}
+ Create specific stages that will help your sales better organise their sales pipeline by maintaining them to their sales opportunities. It will allow them to easily track how is positioned a specific opportunity in the sales cycle.
+
+
+
+
Opportunities
@@ -15,12 +30,12 @@
+ domain="[('type','=','opportunity'),('section_ids', '=', section_id)]"/>
+ type="object" icon="gtk-go-forward" string="" context="{'stage_type': 'opportunity'}"/>
@@ -303,7 +318,7 @@
-
+
diff --git a/addons/crm/crm_view.xml b/addons/crm/crm_view.xml
index b387ef7288e..8de6b3ab3a6 100644
--- a/addons/crm/crm_view.xml
+++ b/addons/crm/crm_view.xml
@@ -7,6 +7,9 @@
+
+
@@ -119,7 +122,7 @@