diff --git a/addons/board/__openerp__.py b/addons/board/__openerp__.py index 605840c2309..0312636a585 100644 --- a/addons/board/__openerp__.py +++ b/addons/board/__openerp__.py @@ -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, } diff --git a/addons/board/controllers/main.py b/addons/board/controllers/main.py index 6eb0890ea46..5f17afd8bb9 100644 --- a/addons/board/controllers/main.py +++ b/addons/board/controllers/main.py @@ -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') diff --git a/addons/board/models/board.py b/addons/board/models/board.py index 08489d99e4a..56742a9eb26 100644 --- a/addons/board/models/board.py +++ b/addons/board/models/board.py @@ -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'): diff --git a/addons/board/static/src/xml/board.xml b/addons/board/static/src/xml/board.xml index 7472441c679..bb3328340b9 100644 --- a/addons/board/static/src/xml/board.xml +++ b/addons/board/static/src/xml/board.xml @@ -1,3 +1,4 @@ +