From 7967ba417db5bdc2a2ba4a850caa38d71c412fce Mon Sep 17 00:00:00 2001 From: "Mayur Maheshwari (OpenERP)" Date: Fri, 6 Apr 2012 14:46:23 +0530 Subject: [PATCH] [IMP]crm: Improved a state field based on stage bzr revid: mma@tinyerp.com-20120406091623-9nqb5lryhueku068 --- addons/crm/crm.py | 6 ++++++ addons/crm/crm_lead.py | 6 +----- addons/crm/crm_lead_view.xml | 14 +++++++------- addons/crm/crm_view.xml | 1 + 4 files changed, 15 insertions(+), 12 deletions(-) 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 @@ - - + +