res = next.action_launch(context=context)
res['nodestroy'] = False
return res
- #if there is no next action and if html is in the context: reload instead of closing
- if context and 'html' in context:
- return {'type' : 'ir.actions.reload'}
- return {'type' : 'ir.actions.act_window_close'}
+ # reload the client; open the first available root menu
+ menu_obj = self.pool.get('ir.ui.menu')
+ menu_ids = menu_obj.search(cr, uid, [('parent_id', '=', False)], context=context)
+ return {
+ 'type': 'ir.actions.client',
+ 'tag': 'reload',
+ 'params': {'menu_id': menu_ids and menu_ids[0] or False},
+ }
def start(self, cr, uid, ids, context=None):
return self.next(cr, uid, ids, context)
'tag': 'reload',
}
+ def cancel(self, cr, uid, ids, context=None):
+ # ignore the current record, and send the action to reopen the view
+ act_window = self.pool.get('ir.actions.act_window')
+ action_ids = act_window.search(cr, uid, [('res_model', '=', self._name)])
+ if action_ids:
+ return act_window.read(cr, uid, action_ids[0], [], context=context)
+ return {}
+
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: