diff --git a/addons/crm/crm.py b/addons/crm/crm.py
index 6fa84a83560..3eaecfb6fd1 100644
--- a/addons/crm/crm.py
+++ b/addons/crm/crm.py
@@ -71,12 +71,18 @@ class crm_case_stage(osv.osv):
'on_change': fields.boolean('Change Probability Automatically', help="Setting this stage will change the probability automatically on the opportunity."),
'requirements': fields.text('Requirements'),
'section_ids':fields.many2many('crm.case.section', 'section_stage_rel', 'stage_id', 'section_id', 'Sections'),
+ 'state': fields.selection(AVAILABLE_STATES, 'State', size=16,
+ help='The state is set to \'Draft\', when a case is created.\
+ \nIf the case is in progress the state is set to \'Open\'.\
+ \nWhen the case is over, the state is set to \'Done\'.\
+ \nIf the case needs to be reviewed then the state is set to \'Pending\'.'),
'case_default': fields.boolean('Common to All Teams', help="If you check this field, this stage will be proposed by default on each sales team. It will not assign this stage to existing teams."),
}
_defaults = {
'sequence': lambda *args: 1,
'probability': lambda *args: 0.0,
+ 'state': lambda *a: 'draft',
}
class crm_case_section(osv.osv):
diff --git a/addons/crm/crm_lead.py b/addons/crm/crm_lead.py
index 2b319e565da..98dff1be9f1 100644
--- a/addons/crm/crm_lead.py
+++ b/addons/crm/crm_lead.py
@@ -175,11 +175,7 @@ class crm_lead(crm_case, osv.osv):
multi='day_open', type="float", store=True),
'day_close': fields.function(_compute_day, string='Days to Close', \
multi='day_close', type="float", store=True),
- 'state': fields.selection(crm.AVAILABLE_STATES, 'State', size=16, readonly=True,
- help='The state is set to \'Draft\', when a case is created.\
- \nIf the case is in progress the state is set to \'Open\'.\
- \nWhen the case is over, the state is set to \'Done\'.\
- \nIf the case needs to be reviewed then the state is set to \'Pending\'.'),
+ 'state': fields.related('stage_id','state', type='char', selection=crm.AVAILABLE_STATES, string="State", store=True, readonly=True),
'message_ids': fields.one2many('mail.message', 'res_id', 'Messages', domain=[('model','=',_name)]),
'subjects': fields.function(_get_email_subject, fnct_search=_history_search, string='Subject of Email', type='char', size=64),
diff --git a/addons/crm/crm_lead_view.xml b/addons/crm/crm_lead_view.xml
index a0a17e9b985..7538cb28503 100644
--- a/addons/crm/crm_lead_view.xml
+++ b/addons/crm/crm_lead_view.xml
@@ -503,8 +503,8 @@
-
-
+
+
@@ -618,7 +618,7 @@
-
+
@@ -638,15 +638,15 @@
+ domain="[('state','=','draft')]" groups="base.group_no_one"/>
+ domain="[('state','=','open')]" groups="base.group_no_one"/>
+ domain="[('state','=','pending')]" groups="base.group_no_one"/>
@@ -679,7 +679,7 @@
-
+
diff --git a/addons/crm/crm_view.xml b/addons/crm/crm_view.xml
index 3df7b002cec..00beef9415e 100644
--- a/addons/crm/crm_view.xml
+++ b/addons/crm/crm_view.xml
@@ -162,6 +162,7 @@
+