[FIX] board: correct /board/add_to_dashboard to use new @route decorator and request object
bzr revid: chs@openerp.com-20131022131049-lb6mva47y0i3kpvq
This commit is contained in:
parent
d97bd2bce2
commit
91fdcc63a7
|
@ -1,24 +1,22 @@
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
from xml.etree import ElementTree
|
from xml.etree import ElementTree
|
||||||
|
|
||||||
import openerp
|
|
||||||
from openerp.addons.web.controllers.main import load_actions_from_ir_values
|
from openerp.addons.web.controllers.main import load_actions_from_ir_values
|
||||||
|
from openerp.addons.web.http import Controller, route, request
|
||||||
|
|
||||||
class Board(openerp.addons.web.http.Controller):
|
class Board(Controller):
|
||||||
_cp_path = '/board'
|
@route('/board/add_to_dashboard', type='json', auth='user')
|
||||||
|
def add_to_dashboard(self, menu_id, action_id, context_to_save, domain, view_mode, name=''):
|
||||||
@openerp.addons.web.http.jsonrequest
|
|
||||||
def add_to_dashboard(self, req, menu_id, action_id, context_to_save, domain, view_mode, name=''):
|
|
||||||
# FIXME move this method to board.board model
|
# FIXME move this method to board.board model
|
||||||
dashboard_action = load_actions_from_ir_values(
|
dashboard_action = load_actions_from_ir_values('action', 'tree_but_open',
|
||||||
req, 'action', 'tree_but_open', [('ir.ui.menu', menu_id)], False)
|
[('ir.ui.menu', menu_id)], False)
|
||||||
|
|
||||||
if dashboard_action:
|
if dashboard_action:
|
||||||
action = dashboard_action[0][2]
|
action = dashboard_action[0][2]
|
||||||
if action['res_model'] == 'board.board' and action['views'][0][1] == 'form':
|
if action['res_model'] == 'board.board' and action['views'][0][1] == 'form':
|
||||||
# Maybe should check the content instead of model board.board ?
|
# Maybe should check the content instead of model board.board ?
|
||||||
view_id = action['views'][0][0]
|
view_id = action['views'][0][0]
|
||||||
board = req.session.model(action['res_model']).fields_view_get(view_id, 'form')
|
board = request.session.model(action['res_model']).fields_view_get(view_id, 'form')
|
||||||
if board and 'arch' in board:
|
if board and 'arch' in board:
|
||||||
xml = ElementTree.fromstring(board['arch'])
|
xml = ElementTree.fromstring(board['arch'])
|
||||||
column = xml.find('./board/column')
|
column = xml.find('./board/column')
|
||||||
|
@ -32,10 +30,10 @@ class Board(openerp.addons.web.http.Controller):
|
||||||
})
|
})
|
||||||
column.insert(0, new_action)
|
column.insert(0, new_action)
|
||||||
arch = ElementTree.tostring(xml, 'utf-8')
|
arch = ElementTree.tostring(xml, 'utf-8')
|
||||||
return req.session.model('ir.ui.view.custom').create({
|
return request.session.model('ir.ui.view.custom').create({
|
||||||
'user_id': req.session._uid,
|
'user_id': request.session.uid,
|
||||||
'ref_id': view_id,
|
'ref_id': view_id,
|
||||||
'arch': arch
|
'arch': arch
|
||||||
}, req.context)
|
}, request.context)
|
||||||
|
|
||||||
return False
|
return False
|
||||||
|
|
Loading…
Reference in New Issue