将Odoo Dashboard分享给所有用户

时间:2016-08-10 13:44:46

标签: python openerp odoo-8 dashboard

如何为所有用户共享我的自定义仪表板,我发现创建的每个自定义仪表板都存储在自定义视图中,然后共享仪表板,您应该复制与该仪表板对应的自定义视图,并更改用户字段。 / p>

有更好的解决方案吗?

2 个答案:

答案 0 :(得分:1)

您可以通过覆盖默认的主板模块并删除用户过滤器来应用解决方法。

from openerp import SUPERUSER_ID
from openerp.osv import fields, osv

from operator import itemgetter
from textwrap import dedent

class board(osv.osv):

    _inherit = 'board.board'

    def fields_view_get(self, cr, user, view_id=None, view_type='form', context=None, toolbar=False, submenu=False):

        user = SUPERUSER_ID
        res = {}
        res = super(board, self).fields_view_get(cr, user, view_id, view_type,
                                                       context=context, toolbar=toolbar, submenu=submenu)

        CustView = self.pool.get('ir.ui.view.custom')
        vids = CustView.search(cr, 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': []}

        return res

class board_create(osv.osv_memory):

    _inherit = 'board.create'

    def board_create(self, cr, uid, ids, context=None):
        assert len(ids) == 1

        uid = SUPERUSER_ID
        res = super(board_create, self).board_create(cr, uid, ids, context=None)

        return res

答案 1 :(得分:0)

我担心如果不改变Odoo的一些基本元素,除了复制视图和更改用户之外没有其他解决方案,因为现场用户是必需的。