This commit introduces models related to sharing dashboard, and implements the sharing from dashboard view. The basic idea is the same as sharing normal spreadsheet. The major difference is that sharing a dashboard will direct to the dashboard view instead of read-only spreadsheet view. A button and a side panel which shows the global filters show up only in the dashboard view. task 3378150 closes odoo/odoo#127370 Related: odoo/enterprise#43664 Signed-off-by: Lucas Lefèvre (lul) <lul@odoo.com> Co-authored-by: Lucas Lefèvre <lul@odoo.com>
35 lines
1.1 KiB
Python
35 lines
1.1 KiB
Python
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
|
|
|
from odoo import Command
|
|
from odoo.tests.common import TransactionCase, new_test_user
|
|
|
|
class DashboardTestCommon(TransactionCase):
|
|
@classmethod
|
|
def setUpClass(cls):
|
|
super().setUpClass()
|
|
cls.group = cls.env["res.groups"].create({"name": "test group"})
|
|
cls.user = new_test_user(cls.env, login="Raoul")
|
|
cls.user.groups_id |= cls.group
|
|
|
|
def create_dashboard(self):
|
|
dashboard_group = self.env["spreadsheet.dashboard.group"].create({
|
|
"name": "Dashboard group"
|
|
})
|
|
dashboard = self.env["spreadsheet.dashboard"].create(
|
|
{
|
|
"name": "a dashboard",
|
|
"group_ids": [Command.set(self.group.ids)],
|
|
"dashboard_group_id": dashboard_group.id,
|
|
}
|
|
)
|
|
return dashboard
|
|
|
|
def share_dashboard(self, dashboard):
|
|
share = self.env["spreadsheet.dashboard.share"].create(
|
|
{
|
|
"dashboard_id": dashboard.id,
|
|
"spreadsheet_data": dashboard.spreadsheet_data,
|
|
}
|
|
)
|
|
return share
|