与所有用户共享 Odoo 仪表板

Share Odoo Dashboard to all users

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

有更好的解决方案吗?

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

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

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

有一个记录规则可以防止其他用户看到自己的仪表板,禁用该记录规则将使一个仪表板对其他用户可见