[IMP]when click on stage base action rule can not worked as clicked on button

bzr revid: sgo@tinyerp.com-20121122121915-n7lkg953e06t89c3
This commit is contained in:
Sanjay Gohel (Open ERP) 2012-11-22 17:49:15 +05:30
parent f1f21379fa
commit 64b74c9000
1 changed files with 9 additions and 14 deletions

View File

@ -202,9 +202,7 @@ class base_stage(object):
def case_escalate(self, cr, uid, ids, context=None):
""" Escalates case to parent level """
cases = self.browse(cr, uid, ids, context=context)
cases[0].state # fill browse record cache, for _action having old and new values
for case in cases:
for case in self.browse(cr, uid, ids, context=context):
data = {'active': True}
if case.section_id.parent_id:
data['section_id'] = case.section_id.parent_id.id
@ -215,8 +213,6 @@ class base_stage(object):
raise osv.except_osv(_('Error!'), _("You are already at the top level of your sales-team category.\nTherefore you cannot escalate furthermore."))
self.write(cr, uid, [case.id], data, context=context)
case.case_escalate_send_note(case.section_id.parent_id, context=context)
cases = self.browse(cr, uid, ids, context=context)
self._action(cr, uid, cases, 'escalate', context=context)
return True
def case_open(self, cr, uid, ids, context=None):
@ -256,8 +252,7 @@ class base_stage(object):
def case_set(self, cr, uid, ids, new_state_name=None, values_to_update=None, new_stage_id=None, context=None):
""" Generic method for setting case. This methods wraps the update
of the record, as well as call to _action and browse_record
case setting to fill the cache.
of the record.
:params new_state_name: the new state of the record; this method
will call ``stage_set_with_state_name``
@ -271,7 +266,6 @@ class base_stage(object):
update when writing values to the record.
"""
cases = self.browse(cr, uid, ids, context=context)
cases[0].state # fill browse record cache, for _action having old and new values
# 1. update the stage
if new_state_name:
self.stage_set_with_state_name(cr, uid, cases, new_state_name, context=context)
@ -280,13 +274,14 @@ class base_stage(object):
# 2. update values
if values_to_update:
self.write(cr, uid, ids, values_to_update, context=context)
# 3. call _action for base action rule
if new_state_name:
self._action(cr, uid, cases, new_state_name, context=context)
elif not (new_stage_id is None):
new_state_name = self.read(cr, uid, ids, ['state'], context=context)[0]['state']
self._action(cr, uid, cases, new_state_name, context=context)
return True
def write(self, cr, uid, ids, vals, context=None):
res = super(base_stage,self).write(cr, uid, ids, vals, context)
if vals.get('stage_id'):
for case in self.browse(cr, uid, ids, context=context):
self._action(cr, uid, case, case.stage_id.state, context=context)
return res
def _action(self, cr, uid, cases, state_to, scrit=None, context=None):
if context is None: