[IMP]: crm_project: Added button + function for previous/next stage in issue's view
bzr revid: rpa@openerp.co.in-20100216124327-0dm39filbiyq34qy
This commit is contained in:
+24
-11
@@ -282,16 +282,7 @@ class crm_case(osv.osv):
|
||||
return super(crm_case, self).unlink(cr, uid, ids, context)
|
||||
|
||||
def stage_next(self, cr, uid, ids, context={}):
|
||||
ok = False
|
||||
sid = self.pool.get('crm.case.stage').search(cr, uid, [('object_id.model', '=', self._name)], context=context)
|
||||
s = {}
|
||||
previous = {}
|
||||
for stage in self.pool.get('crm.case.stage').browse(cr, uid, sid, context=context):
|
||||
section = stage.section_id.id or False
|
||||
s.setdefault(section, {})
|
||||
s[section][previous.get(section, False)] = stage.id
|
||||
previous[section] = stage.id
|
||||
|
||||
s = self.get_stage_dict(cr, uid, ids, context=context)
|
||||
for case in self.browse(cr, uid, ids, context):
|
||||
section = (case.section_id.id or False)
|
||||
if section in s:
|
||||
@@ -300,7 +291,29 @@ class crm_case(osv.osv):
|
||||
self.write(cr, uid, [case.id], {'stage_id': s[section][st]})
|
||||
|
||||
return True
|
||||
|
||||
|
||||
def get_stage_dict(self, cr, uid, ids, context={}):
|
||||
sid = self.pool.get('crm.case.stage').search(cr, uid, [('object_id.model', '=', self._name)], context=context)
|
||||
s = {}
|
||||
previous = {}
|
||||
for stage in self.pool.get('crm.case.stage').browse(cr, uid, sid, context=context):
|
||||
section = stage.section_id.id or False
|
||||
s.setdefault(section, {})
|
||||
s[section][previous.get(section, False)] = stage.id
|
||||
previous[section] = stage.id
|
||||
return s
|
||||
|
||||
def stage_previous(self, cr, uid, ids, context={}):
|
||||
s = self.get_stage_dict(cr, uid, ids, context=context)
|
||||
for case in self.browse(cr, uid, ids, context):
|
||||
section = (case.section_id.id or False)
|
||||
if section in s:
|
||||
st = case.stage_id.id or False
|
||||
s[section] = dict([(v, k) for (k, v) in s[section].iteritems()])
|
||||
if st in s[section]:
|
||||
self.write(cr, uid, [case.id], {'stage_id': s[section][st]})
|
||||
return True
|
||||
|
||||
def onchange_categ_id(self, cr, uid, ids, categ, context={}):
|
||||
if not categ:
|
||||
return {'value':{}}
|
||||
|
||||
@@ -72,8 +72,9 @@
|
||||
<field name="priority" string="Severity"/>
|
||||
<field name="user_id" />
|
||||
<label string="Resolution: " align="1.0"/>
|
||||
<group colspan="1" col="2">
|
||||
<group colspan="1" col="3">
|
||||
<field name="stage_id" select="1" nolabel="1"/>
|
||||
<button icon="gtk-go-back" string="" name="stage_previous" type="object"/>
|
||||
<button icon="gtk-go-forward" string="" name="stage_next" type="object"/>
|
||||
</group>
|
||||
</group>
|
||||
@@ -157,6 +158,12 @@
|
||||
<field name="partner_id"/>
|
||||
<field name="priority" string="Severity"/>
|
||||
<field name="stage_id" string="Resolution"/>
|
||||
<button icon="gtk-go-back" string=""
|
||||
name="stage_previous" type="object"
|
||||
states="open,draft,pending,done,cancel" />
|
||||
<button icon="gtk-go-forward" string=""
|
||||
name="stage_next" type="object"
|
||||
states="open,draft,pending,done,cancel" />
|
||||
<field name="type_id" string="Version"/>
|
||||
<field name="user_id"/>
|
||||
<field name="state"/>
|
||||
|
||||
Reference in New Issue
Block a user