Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 6 additions & 10 deletions spreadsheet_dashboard_oca/README.rst
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
.. image:: https://odoo-community.org/readme-banner-image
:target: https://odoo-community.org/get-involved?utm_source=readme
:alt: Odoo Community Association

=========================
Spreadsheet Dashboard Oca
=========================
Expand All @@ -17,7 +13,7 @@ Spreadsheet Dashboard Oca
.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
:target: https://odoo-community.org/page/development-status
:alt: Beta
.. |badge2| image:: https://img.shields.io/badge/license-AGPL--3-blue.png
.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
:alt: License: AGPL-3
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fspreadsheet-lightgray.png?logo=github
Expand Down Expand Up @@ -61,14 +57,14 @@ Authors
Contributors
------------

- Enric Tobella
- `Tecnativa <https://www.tecnativa.com>`__:
- Enric Tobella
- `Tecnativa <https://www.tecnativa.com>`__:

- Carlos Roca
- Carlos Roca

- `Open User Systems <https://www.openusersystems.com>`__:
- `Open User Systems <https://www.openusersystems.com>`__:

- Chris Mann
- Chris Mann

Maintainers
-----------
Expand Down
11 changes: 11 additions & 0 deletions spreadsheet_dashboard_oca/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,20 @@
"spreadsheet_oca",
],
"data": [
"security/ir.model.access.csv",
"wizards/spreadsheet_spreadsheet_import.xml",
"wizards/spreadsheet_to_dashboard.xml",
"views/spreadsheet_dashboard_group_views.xml",
"views/spreadsheet_dashboard.xml",
"data/spreadsheet_spreadsheet_import_mode.xml",
],
"assets": {
"spreadsheet.o_spreadsheet": [
(
"after",
"spreadsheet/static/src/o_spreadsheet/o_spreadsheet.js",
"spreadsheet_dashboard_oca/static/src/bundle/*.js",
),
],
},
}
2 changes: 2 additions & 0 deletions spreadsheet_dashboard_oca/security/ir.model.access.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
access_spreadsheet_to_dashboard_wizard,spreadsheet.to.dashboard.wizard.access,model_spreadsheet_to_dashboard,base.group_user,1,1,1,0
24 changes: 9 additions & 15 deletions spreadsheet_dashboard_oca/static/description/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="generator" content="Docutils: https://docutils.sourceforge.io/" />
<title>README.rst</title>
<title>Spreadsheet Dashboard Oca</title>
<style type="text/css">

/*
Expand Down Expand Up @@ -360,21 +360,16 @@
</style>
</head>
<body>
<div class="document">
<div class="document" id="spreadsheet-dashboard-oca">
<h1 class="title">Spreadsheet Dashboard Oca</h1>


<a class="reference external image-reference" href="https://odoo-community.org/get-involved?utm_source=readme">
<img alt="Odoo Community Association" src="https://odoo-community.org/readme-banner-image" />
</a>
<div class="section" id="spreadsheet-dashboard-oca">
<h1>Spreadsheet Dashboard Oca</h1>
<!-- !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:3cc11a34f632c64341e2dee08d3fc582e30f6a13f049b460e154768d0368a7e6
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
<p><a class="reference external image-reference" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external image-reference" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/license-AGPL--3-blue.png" /></a> <a class="reference external image-reference" href="https://github.com/OCA/spreadsheet/tree/18.0/spreadsheet_dashboard_oca"><img alt="OCA/spreadsheet" src="https://img.shields.io/badge/github-OCA%2Fspreadsheet-lightgray.png?logo=github" /></a> <a class="reference external image-reference" href="https://translation.odoo-community.org/projects/spreadsheet-18-0/spreadsheet-18-0-spreadsheet_dashboard_oca"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external image-reference" href="https://runboat.odoo-community.org/builds?repo=OCA/spreadsheet&amp;target_branch=18.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
<p><a class="reference external image-reference" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external image-reference" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/licence-AGPL--3-blue.png" /></a> <a class="reference external image-reference" href="https://github.com/OCA/spreadsheet/tree/18.0/spreadsheet_dashboard_oca"><img alt="OCA/spreadsheet" src="https://img.shields.io/badge/github-OCA%2Fspreadsheet-lightgray.png?logo=github" /></a> <a class="reference external image-reference" href="https://translation.odoo-community.org/projects/spreadsheet-18-0/spreadsheet-18-0-spreadsheet_dashboard_oca"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external image-reference" href="https://runboat.odoo-community.org/builds?repo=OCA/spreadsheet&amp;target_branch=18.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
<p>This module allows to edit spreadsheet dashboards using OCA Spreadsheet
editor.</p>
<p><strong>Table of contents</strong></p>
Expand All @@ -390,23 +385,23 @@ <h1>Spreadsheet Dashboard Oca</h1>
</ul>
</div>
<div class="section" id="bug-tracker">
<h2><a class="toc-backref" href="#toc-entry-1">Bug Tracker</a></h2>
<h1><a class="toc-backref" href="#toc-entry-1">Bug Tracker</a></h1>
<p>Bugs are tracked on <a class="reference external" href="https://github.com/OCA/spreadsheet/issues">GitHub Issues</a>.
In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us to smash it by providing a detailed and welcomed
<a class="reference external" href="https://github.com/OCA/spreadsheet/issues/new?body=module:%20spreadsheet_dashboard_oca%0Aversion:%2018.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
<p>Do not contact contributors directly about support or help with technical issues.</p>
</div>
<div class="section" id="credits">
<h2><a class="toc-backref" href="#toc-entry-2">Credits</a></h2>
<h1><a class="toc-backref" href="#toc-entry-2">Credits</a></h1>
<div class="section" id="authors">
<h3><a class="toc-backref" href="#toc-entry-3">Authors</a></h3>
<h2><a class="toc-backref" href="#toc-entry-3">Authors</a></h2>
<ul class="simple">
<li>CreuBlanca</li>
</ul>
</div>
<div class="section" id="contributors">
<h3><a class="toc-backref" href="#toc-entry-4">Contributors</a></h3>
<h2><a class="toc-backref" href="#toc-entry-4">Contributors</a></h2>
<ul class="simple">
<li>Enric Tobella</li>
<li><a class="reference external" href="https://www.tecnativa.com">Tecnativa</a>:<ul>
Expand All @@ -420,7 +415,7 @@ <h3><a class="toc-backref" href="#toc-entry-4">Contributors</a></h3>
</ul>
</div>
<div class="section" id="maintainers">
<h3><a class="toc-backref" href="#toc-entry-5">Maintainers</a></h3>
<h2><a class="toc-backref" href="#toc-entry-5">Maintainers</a></h2>
<p>This module is maintained by the OCA.</p>
<a class="reference external image-reference" href="https://odoo-community.org">
<img alt="Odoo Community Association" src="https://odoo-community.org/logo.png" />
Expand All @@ -433,6 +428,5 @@ <h3><a class="toc-backref" href="#toc-entry-5">Maintainers</a></h3>
</div>
</div>
</div>
</div>
</body>
</html>
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
import * as spreadsheet from "@odoo/o-spreadsheet";
import {useState, useSubEnv} from "@odoo/owl";
import {SpreadsheetRenderer} from "@spreadsheet_oca/spreadsheet/bundle/spreadsheet_renderer.esm";
import {_t} from "@web/core/l10n/translation";
import {patch} from "@web/core/utils/patch";
const {topbarMenuRegistry} = spreadsheet.registries;
import {user} from "@web/core/user";

topbarMenuRegistry.addChild("add_to_dashboard", ["file"], {
name: _t("Add to dashboard"),
sequence: 120,
execute: (env) => env.addToDashboard(),
isVisible: (env) => env.canAddToDashboard?.(),
icon: "o-spreadsheet-Icon.INSERT_CHART",
});

patch(SpreadsheetRenderer.prototype, {
setup() {
super.setup();
this.state = useState({canAddToDashboard: false});
this._checkDashboardPermission();
useSubEnv({
addToDashboard: this._addToDashboard.bind(this),
canAddToDashboard: () => this.state.canAddToDashboard,
});
},
async _checkDashboardPermission() {
const result =
(await user.hasGroup("base.group_system")) ||
(await user.hasGroup("spreadsheet_dashboard.group_dashboard_manager"));
this.state.canAddToDashboard = result;
},
async _addToDashboard() {
const record = this.props.record;
const resId = this.props.res_id;
const name = record.name;
this.onSpreadsheetSaved();
this.env.services.action.doAction(
{
name: _t("Add to dashboard"),
type: "ir.actions.act_window",
view_mode: "form",
views: [[false, "form"]],
target: "new",
res_model: "spreadsheet.to.dashboard",
},
{
additionalContext: {
default_spreadsheet_id: resId,
default_name: name,
},
}
);
},
});
2 changes: 1 addition & 1 deletion spreadsheet_dashboard_oca/wizards/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
from . import spreadsheet_spreadsheet_import
from . import spreadsheet_spreadsheet_import, spreadsheet_to_dashboard
62 changes: 62 additions & 0 deletions spreadsheet_dashboard_oca/wizards/spreadsheet_to_dashboard.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
# Copyright 2025 Open User Systems
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

import json

from odoo import api, fields, models


class SpreadsheetToDashboard(models.TransientModel):
_name = "spreadsheet.to.dashboard"
_description = "Create dashboard from spreadsheet"

name = fields.Char(
"Dashboard Name",
required=True,
compute="_compute_name",
store=True,
readonly=False,
precompute=True,
)
spreadsheet_id = fields.Many2one(
"spreadsheet.spreadsheet",
readonly=True,
required=True,
)
dashboard_group_id = fields.Many2one(
"spreadsheet.dashboard.group", string="Dashboard Section", required=True
)
group_ids = fields.Many2many(
"res.groups",
default=lambda self: self._default_group_ids(),
string="User Groups",
)

def _default_group_ids(self):
return self.env["spreadsheet.dashboard"].default_get(["group_ids"])["group_ids"]

@api.depends("spreadsheet_id.name")
def _compute_name(self):
for rec in self:
rec.name = rec.spreadsheet_id.name

def create_dashboard(self):
self.ensure_one()
spreadsheet_data = self.spreadsheet_id.get_spreadsheet_data()
spreadsheet_raw = spreadsheet_data["spreadsheet_raw"]
dashboard = self.env["spreadsheet.dashboard"].create(
{
"name": self.name,
"dashboard_group_id": self.dashboard_group_id.id,
"group_ids": self.group_ids.ids,
"spreadsheet_data": json.dumps(spreadsheet_raw),
}
)
return {
"type": "ir.actions.client",
"tag": "action_spreadsheet_dashboard",
"name": self.name,
"params": {
"dashboard_id": dashboard.id,
},
}
32 changes: 32 additions & 0 deletions spreadsheet_dashboard_oca/wizards/spreadsheet_to_dashboard.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?xml version="1.0" encoding="utf-8" ?>
<odoo>
<record id="spreadsheet_to_dashboard_view_form" model="ir.ui.view">
<field name="name">spreadsheet.to.dashboard.view.form</field>
<field name="model">spreadsheet.to.dashboard</field>
<field name="arch" type="xml">
<form>
<group>
<group>
<field name="name" />
<field
name="dashboard_group_id"
options="{'no_open': True, 'no_create_edit': True}"
/>
</group>
<group>
<field name="group_ids" widget="many2many_tags" />
</group>
</group>
<footer>
<button
string="Create"
name="create_dashboard"
type="object"
class="btn-primary"
/>
<button string="Cancel" class="btn-secondary" special="cancel" />
</footer>
</form>
</field>
</record>
</odoo>