[IMP] crm (crm_case, crm_lead): fixed case_oen in crm_base/crm_case (writes date_open if was in draft); deleted case_open in crm_lead as its behavior is now the default crm_case behavior; updated opportunities form view (re-added a Open button, when in draft; rearranged buttons).

bzr revid: tde@openerp.com-20120521142317-3cwzxc2vdn1h3sjo
This commit is contained in:
Thibault Delavallée 2012-05-21 16:23:17 +02:00
parent 4ef4b635f7
commit f7e053f078
3 changed files with 14 additions and 20 deletions

View File

@ -263,7 +263,9 @@ class crm_base(object):
""" Opens case """
cases = self.browse(cr, uid, ids, context=context)
for case in cases:
data = {'state': 'open', 'date_open': fields.datetime.now(), 'active': True}
data = {'state': 'open', 'active': True}
if case.state == 'draft':
data['date_open'] = fields.datetime.now()
if not case.user_id:
data['user_id'] = uid
self.write(cr, uid, [case.id], data, context=context)
@ -443,6 +445,8 @@ class crm_case(crm_base):
self.stage_set_with_state_name(cr, uid, cases, 'open', context=context)
for case in cases:
data = {'active': True, 'date_open': fields.datetime.now()}
if case.stage_id and case.stage_id.state == 'draft':
data['date_open'] = fields.datetime.now()
if not case.user_id:
data['user_id'] = uid
self.write(cr, uid, [case.id], data, context=context)

View File

@ -260,18 +260,6 @@ class crm_lead(crm_case, osv.osv):
def stage_find_won(self, cr, uid, section_id):
return self.stage_find_percent(cr, uid, 100.0, section_id)
def case_open(self, cr, uid, ids, context=None):
for lead in self.browse(cr, uid, ids, context=context):
if lead.state == 'draft':
value = {'date_open': time.strftime('%Y-%m-%d %H:%M:%S')}
self.write(cr, uid, [lead.id], value)
if lead.type == 'opportunity' and not lead.stage_id:
stage_id = self.stage_find(cr, uid, lead.section_id.id or False, [('sequence','>',0)])
if stage_id:
self.stage_set(cr, uid, [lead.id], stage_id)
res = super(crm_lead, self).case_open(cr, uid, ids, context)
return res
def case_cancel(self, cr, uid, ids, context=None):
"""Overrides cancel for crm_case for setting probability
"""
@ -302,7 +290,7 @@ class crm_lead(crm_case, osv.osv):
for lead in self.browse(cr, uid, ids):
stage_id = self.stage_find_won(cr, uid, lead.section_id.id or False)
if stage_id:
self.case_set(cr, uid, [lead.id], values_to_update={'probability': 87.0}, new_stage_id=stage_id, context=context)
self.case_set(cr, uid, [lead.id], values_to_update={'probability': 100.0}, new_stage_id=stage_id, context=context)
self.case_close_send_note(cr, uid, ids, context=context)
return True

View File

@ -403,19 +403,21 @@
<form string="Opportunities" layout="manual">
<div class="oe_form_topbar oe_form_topbar_hifirst">
<button name="stage_previous" string="Previous" type="object"
states="draft,open,pending" icon="gtk-go-back" context="{'stage_type': 'opportunity'}"/>
states="open" icon="gtk-go-back" context="{'stage_type': 'opportunity'}"/>
<button name="stage_next" string="Next" type="object"
states="draft,open,pending" icon="gtk-go-forward" context="{'stage_type': 'opportunity'}"/>
<button name="case_cancel" string="Cancel" type="object"
states="draft" icon="gtk-cancel"/>
states="open" icon="gtk-go-forward" context="{'stage_type': 'opportunity'}"/>
<button name="case_open" string="Open" type="object"
states="draft" icon="gtk-go-forward"/>
<button name="case_escalate" string="Escalate" type="object"
states="open" icon="gtk-go-up"/>
<button name="case_mark_won" string="Mark Won" type="object"
states="open" icon="gtk-apply"/>
<button name="case_mark_lost" string="Mark Lost" type="object"
states="open" icon="gtk-cancel"/>
<button name="case_reset" string="Reset to Draft" type="object"
states="cancel,done" icon="gtk-convert"/>
<button name="case_escalate" string="Escalate" type="object"
states="open" icon="gtk-go-up"/>
<button name="case_cancel" string="Cancel" type="object"
states="draft" icon="gtk-cancel"/>
<div class="oe_right">
<field name="stage_id" nolabel="1" widget="statusbar"
statusbar_visible="New,Qualification,Proposition,Won"