[MIG] board: migrated to new API
This commit is contained in:
committed by
Yannick Tivisse
parent
bf0b752817
commit
7e72de3f2e
@@ -18,8 +18,6 @@ Allows users to create custom dashboard.
|
||||
'views/board_views.xml',
|
||||
'views/board_templates.xml',
|
||||
],
|
||||
'qweb': ['static/src/xml/*.xml'],
|
||||
'installable': True,
|
||||
'qweb': ['static/src/xml/board.xml'],
|
||||
'application': True,
|
||||
'auto_install': False,
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
|
||||
from xml.etree import ElementTree
|
||||
|
||||
from openerp.http import Controller, route, request
|
||||
from odoo.http import Controller, route, request
|
||||
|
||||
|
||||
class Board(Controller):
|
||||
@@ -11,12 +11,12 @@ class Board(Controller):
|
||||
@route('/board/add_to_dashboard', type='json', auth='user')
|
||||
def add_to_dashboard(self, action_id, context_to_save, domain, view_mode, name=''):
|
||||
# Retrieve the 'My Dashboard' action from its xmlid
|
||||
action = request.env['ir.model.data'].get_object('board', 'open_board_my_dash_action')
|
||||
action = request.env.ref('board.open_board_my_dash_action')
|
||||
|
||||
if action and action['res_model'] == 'board.board' and action['views'][0][1] == 'form':
|
||||
# Maybe should check the content instead of model board.board ?
|
||||
view_id = action['views'][0][0]
|
||||
board = request.env[action['res_model']].fields_view_get(view_id, 'form')
|
||||
board = request.env['board.board'].fields_view_get(view_id, 'form')
|
||||
if board and 'arch' in board:
|
||||
xml = ElementTree.fromstring(board['arch'])
|
||||
column = xml.find('./board/column')
|
||||
|
||||
@@ -1,44 +1,41 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
||||
|
||||
from operator import itemgetter
|
||||
from textwrap import dedent
|
||||
from odoo import api, models
|
||||
|
||||
from openerp import tools, SUPERUSER_ID
|
||||
from openerp.osv import fields, osv
|
||||
|
||||
class board_board(osv.osv):
|
||||
class Board(models.Model):
|
||||
_name = 'board.board'
|
||||
_description = "Board"
|
||||
_auto = False
|
||||
_columns = {}
|
||||
|
||||
def create(self, cr, user, vals, context=None):
|
||||
return 0
|
||||
@api.model
|
||||
def create(self, vals):
|
||||
return self
|
||||
|
||||
def fields_view_get(self, cr, user, view_id=None, view_type='form', context=None, toolbar=False, submenu=False):
|
||||
@api.model
|
||||
def fields_view_get(self, view_id=None, view_type='form', toolbar=False, submenu=False):
|
||||
"""
|
||||
Overrides orm field_view_get.
|
||||
@return: Dictionary of Fields, arch and toolbar.
|
||||
"""
|
||||
|
||||
res = {}
|
||||
res = super(board_board, self).fields_view_get(cr, user, view_id=view_id, view_type=view_type,
|
||||
context=context, toolbar=toolbar, submenu=submenu)
|
||||
res = super(Board, self).fields_view_get(view_id=view_id, view_type=view_type, toolbar=toolbar, submenu=submenu)
|
||||
|
||||
CustView = self.pool.get('ir.ui.view.custom')
|
||||
vids = CustView.search(cr, user, [('user_id', '=', user), ('ref_id', '=', view_id)], context=context)
|
||||
if vids:
|
||||
view_id = vids[0]
|
||||
arch = CustView.browse(cr, user, view_id, context=context)
|
||||
res['custom_view_id'] = view_id
|
||||
res['arch'] = arch.arch
|
||||
res['arch'] = self._arch_preprocessing(cr, user, res['arch'], context=context)
|
||||
res['toolbar'] = {'print': [], 'action': [], 'relate': []}
|
||||
custom_view = self.env['ir.ui.view.custom'].search([('user_id', '=', self.env.uid), ('ref_id', '=', view_id)], limit=1)
|
||||
if custom_view:
|
||||
res.update({'custom_view_id': custom_view.id,
|
||||
'arch': custom_view.arch})
|
||||
res.update({
|
||||
'arch': self._arch_preprocessing(res['arch']),
|
||||
'toolbar': {'print': [], 'action': [], 'relate': []}
|
||||
})
|
||||
return res
|
||||
|
||||
def _arch_preprocessing(self, cr, user, arch, context=None):
|
||||
@api.model
|
||||
def _arch_preprocessing(self, arch):
|
||||
from lxml import etree
|
||||
|
||||
def remove_unauthorized_children(node):
|
||||
for child in node.iterchildren():
|
||||
if child.tag == 'action' and child.get('invisible'):
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<template>
|
||||
<t t-name="DashBoard">
|
||||
<div class="oe_dashboard_links">
|
||||
|
||||
@@ -1,11 +1,9 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<openerp>
|
||||
<data>
|
||||
<odoo>
|
||||
<template id="assets_backend" name="board assets" inherit_id="web.assets_backend">
|
||||
<xpath expr="." position="inside">
|
||||
<link rel="stylesheet" href="/board/static/src/less/dashboard.less"/>
|
||||
<link rel="stylesheet" href="/board/static/src/less/dashboard.less"/>
|
||||
<script type="text/javascript" src="/board/static/src/js/dashboard.js"></script>
|
||||
</xpath>
|
||||
</template>
|
||||
</data>
|
||||
</openerp>
|
||||
</odoo>
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<?xml version="1.0"?>
|
||||
<openerp>
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<odoo>
|
||||
<data noupdate="1">
|
||||
<!--My Dashboard-->
|
||||
<record model="ir.ui.view" id="board_my_dash_view">
|
||||
@@ -46,4 +46,4 @@
|
||||
action="open_board_my_dash_action"
|
||||
sequence="5"/>
|
||||
</data>
|
||||
</openerp>
|
||||
</odoo>
|
||||
|
||||
Reference in New Issue
Block a user