Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[16.0][IMP+FIX] spreadsheet*_oca: New field to name the pivot table and fixed error adding to new sheet of dashboard #38

Merged
merged 6 commits into from
Jul 25, 2024
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
3 changes: 3 additions & 0 deletions spreadsheet_dashboard_oca/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@ Contributors
~~~~~~~~~~~~

* Enric Tobella
* `Tecnativa <https://www.tecnativa.com>`_:

* Carlos Roca

Maintainers
~~~~~~~~~~~
Expand Down
1 change: 1 addition & 0 deletions spreadsheet_dashboard_oca/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
"depends": [
"spreadsheet_dashboard",
"spreadsheet_oca",
"base_view_inheritance_extension",
],
"data": [
"wizards/spreadsheet_spreadsheet_import.xml",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,13 @@
<field name="sequence" eval="21" />
<field name="group_ids" eval="[(4, ref('base.group_system'))]" />
</record>
<record
id="spreadsheet_import_mode_dashboard_new_spreadsheet"
model="spreadsheet.spreadsheet.import.mode"
>
<field name="code">dashboard_spreadsheet</field>
<field name="name">New dashboard</field>
<field name="sequence" eval="19" />
<field name="group_ids" eval="[(4, ref('base.group_system'))]" />
</record>
</odoo>
102 changes: 102 additions & 0 deletions spreadsheet_dashboard_oca/i18n/es.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * spreadsheet_dashboard_oca
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 16.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2024-07-19 10:02+0000\n"
"PO-Revision-Date: 2024-07-19 12:03+0200\n"
"Last-Translator: \n"
"Language-Team: \n"
"Language: es\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
"X-Generator: Poedit 3.0.1\n"

#. module: spreadsheet_dashboard_oca
#: model:ir.model.fields,field_description:spreadsheet_dashboard_oca.field_spreadsheet_dashboard__active
msgid "Active"
msgstr "Activo"

#. module: spreadsheet_dashboard_oca
#: model:ir.model.fields,field_description:spreadsheet_dashboard_oca.field_spreadsheet_dashboard__can_edit
msgid "Can Edit"
msgstr "Se puede editar"

#. module: spreadsheet_dashboard_oca
#: model_terms:ir.ui.view,arch_db:spreadsheet_dashboard_oca.spreadsheet_dashboard_tree_view
msgid "Copy"
msgstr "Copiar"

#. module: spreadsheet_dashboard_oca
#: model:ir.model.fields,field_description:spreadsheet_dashboard_oca.field_spreadsheet_spreadsheet_import__dashboard_id
msgid "Dashboard"
msgstr "Tablero"

#. module: spreadsheet_dashboard_oca
#: model:ir.model.fields,field_description:spreadsheet_dashboard_oca.field_spreadsheet_spreadsheet_import__dashboard_group_id
msgid "Dashboard Group"
msgstr "Tablero grupal"

#. module: spreadsheet_dashboard_oca
#: model_terms:ir.ui.view,arch_db:spreadsheet_dashboard_oca.spreadsheet_dashboard_tree_view
msgid "Edit"
msgstr "Editar"

#. module: spreadsheet_dashboard_oca
#: model:ir.model,name:spreadsheet_dashboard_oca.model_spreadsheet_spreadsheet_import
msgid "Import data to spreadsheet"
msgstr "Importar datos a hoja de cálculo"

#. module: spreadsheet_dashboard_oca
#: model:ir.model.fields,field_description:spreadsheet_dashboard_oca.field_spreadsheet_dashboard__name
msgid "Name"
msgstr "Nombre"

#. module: spreadsheet_dashboard_oca
#: model:spreadsheet.spreadsheet.import.mode,name:spreadsheet_dashboard_oca.spreadsheet_import_mode_dashboard_new_spreadsheet
msgid "New dashboard"
msgstr "Nuevo tablero"

#. module: spreadsheet_dashboard_oca
#. odoo-python
#: code:addons/spreadsheet_dashboard_oca/models/spreadsheet_dashboard.py:0
#, python-format
msgid "Search operation not supported"
msgstr "Operación de búsqueda no soportada"

#. module: spreadsheet_dashboard_oca
#: model:ir.model,name:spreadsheet_dashboard_oca.model_spreadsheet_dashboard
msgid "Spreadsheet Dashboard"
msgstr "Hoja de cálculo de tablero"

#. module: spreadsheet_dashboard_oca
#: model:ir.model.fields,field_description:spreadsheet_dashboard_oca.field_spreadsheet_dashboard__spreadsheet_raw
msgid "Spreadsheet Raw"
msgstr "Hoja de cálculo Raw"

#. module: spreadsheet_dashboard_oca
#: model:ir.model.fields,field_description:spreadsheet_dashboard_oca.field_spreadsheet_dashboard__spreadsheet_revision_ids
msgid "Spreadsheet Revision"
msgstr "Revisión de hoja de cálculo"

#. module: spreadsheet_dashboard_oca
#. odoo-python
#: code:addons/spreadsheet_dashboard_oca/models/spreadsheet_dashboard.py:0
#, python-format
msgid "The value has to be a boolean"
msgstr "El valor tiene que ser un booleano"

#. module: spreadsheet_dashboard_oca
#: model:spreadsheet.spreadsheet.import.mode,name:spreadsheet_dashboard_oca.spreadsheet_import_mode_dashboard
msgid "To dashboard"
msgstr "A tablero"

#. module: spreadsheet_dashboard_oca
#: model:spreadsheet.spreadsheet.import.mode,name:spreadsheet_dashboard_oca.spreadsheet_import_mode_dashboard_sheet
msgid "To dashboard new sheet"
msgstr "A tablero en nueva hoja"
26 changes: 26 additions & 0 deletions spreadsheet_dashboard_oca/i18n/spreadsheet_dashboard_oca.pot
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 16.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2024-07-19 10:02+0000\n"
"PO-Revision-Date: 2024-07-19 10:02+0000\n"
"Last-Translator: \n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
Expand Down Expand Up @@ -33,6 +35,11 @@ msgstr ""
msgid "Dashboard"
msgstr ""

#. module: spreadsheet_dashboard_oca
#: model:ir.model.fields,field_description:spreadsheet_dashboard_oca.field_spreadsheet_spreadsheet_import__dashboard_group_id
msgid "Dashboard Group"
msgstr ""

#. module: spreadsheet_dashboard_oca
#: model_terms:ir.ui.view,arch_db:spreadsheet_dashboard_oca.spreadsheet_dashboard_tree_view
msgid "Edit"
Expand All @@ -48,6 +55,18 @@ msgstr ""
msgid "Name"
msgstr ""

#. module: spreadsheet_dashboard_oca
#: model:spreadsheet.spreadsheet.import.mode,name:spreadsheet_dashboard_oca.spreadsheet_import_mode_dashboard_new_spreadsheet
msgid "New dashboard"
msgstr ""

#. module: spreadsheet_dashboard_oca
#. odoo-python
#: code:addons/spreadsheet_dashboard_oca/models/spreadsheet_dashboard.py:0
#, python-format
msgid "Search operation not supported"
msgstr ""

#. module: spreadsheet_dashboard_oca
#: model:ir.model,name:spreadsheet_dashboard_oca.model_spreadsheet_dashboard
msgid "Spreadsheet Dashboard"
Expand All @@ -63,6 +82,13 @@ msgstr ""
msgid "Spreadsheet Revision"
msgstr ""

#. module: spreadsheet_dashboard_oca
#. odoo-python
#: code:addons/spreadsheet_dashboard_oca/models/spreadsheet_dashboard.py:0
#, python-format
msgid "The value has to be a boolean"
msgstr ""

#. module: spreadsheet_dashboard_oca
#: model:spreadsheet.spreadsheet.import.mode,name:spreadsheet_dashboard_oca.spreadsheet_import_mode_dashboard
msgid "To dashboard"
Expand Down
26 changes: 24 additions & 2 deletions spreadsheet_dashboard_oca/models/spreadsheet_dashboard.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
import base64
import json

from odoo import api, fields, models
from odoo import _, api, fields, models
from odoo.exceptions import ValidationError


class SpreadsheetDashboard(models.Model):
Expand All @@ -15,7 +16,7 @@
spreadsheet_raw = fields.Serialized(
inverse="_inverse_spreadsheet_raw", compute="_compute_spreadsheet_raw"
)
can_edit = fields.Boolean(compute="_compute_can_edit")
can_edit = fields.Boolean(compute="_compute_can_edit", search="_search_can_edit")

@api.depends("data")
def _compute_spreadsheet_raw(self):
Expand All @@ -42,3 +43,24 @@
)
if imd and imd.module != "__export__":
record.can_edit = imd.noupdate

@api.model
def _search_can_edit(self, operator, value):
if operator != "=":
raise NotImplementedError(_("Search operation not supported"))

Check warning on line 50 in spreadsheet_dashboard_oca/models/spreadsheet_dashboard.py

View check run for this annotation

Codecov / codecov/patch

spreadsheet_dashboard_oca/models/spreadsheet_dashboard.py#L50

Added line #L50 was not covered by tests
if not isinstance(value, bool):
raise ValidationError(_("The value has to be a boolean"))
no_edit_ids = (

Check warning on line 53 in spreadsheet_dashboard_oca/models/spreadsheet_dashboard.py

View check run for this annotation

Codecov / codecov/patch

spreadsheet_dashboard_oca/models/spreadsheet_dashboard.py#L52-L53

Added lines #L52 - L53 were not covered by tests
self.env["ir.model.data"]
.search(
[
("model", "=", self._name),
("module", "!=", "__export__"),
("noupdate", "=", 0),
]
)
.mapped("res_id")
)
Comment on lines +53 to +63
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I created a brand new dashboard but I can't make it to show up in the wizard. Am I doing something wrong

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You have to add a spreadsheet to the panel to be able to show it

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I mean, I can't select any dashboard in the wizard

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

example

I am able to select it.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was trying to dashboard new sheet. I was expecting to let me choose a dashboard to wich apend a sheet. Did I understand it wrong?

Copy link
Contributor Author

@CarlosRoca13 CarlosRoca13 Jul 19, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes 😅 that option is to add a sheet to a created spreadsheet for the dashboard

Example:
new sheet example

This option can be used to set data that has to be hidden but it has to be used to make some operations

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that option that you say can be set, I will see how to add it

Thanks 😄

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, ok. See? I was getting it wrong 😅

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added new option to create new dashboards 😄

if value:
return [("id", "not in", no_edit_ids)]
return [("id", "in", no_edit_ids)]

Check warning on line 66 in spreadsheet_dashboard_oca/models/spreadsheet_dashboard.py

View check run for this annotation

Codecov / codecov/patch

spreadsheet_dashboard_oca/models/spreadsheet_dashboard.py#L65-L66

Added lines #L65 - L66 were not covered by tests
3 changes: 3 additions & 0 deletions spreadsheet_dashboard_oca/readme/CONTRIBUTORS.rst
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
* Enric Tobella
* `Tecnativa <https://www.tecnativa.com>`_:

* Carlos Roca
15 changes: 11 additions & 4 deletions spreadsheet_dashboard_oca/static/description/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,11 @@

/*
:Author: David Goodger ([email protected])
:Id: $Id: html4css1.css 8954 2022-01-20 10:10:25Z milde $
:Id: $Id: html4css1.css 9511 2024-01-13 09:50:07Z milde $
:Copyright: This stylesheet has been placed in the public domain.

Default cascading style sheet for the HTML output of Docutils.
Despite the name, some widely supported CSS2 features are used.

See https://docutils.sourceforge.io/docs/howto/html-stylesheets.html for how to
customize this style sheet.
Expand Down Expand Up @@ -274,7 +275,7 @@
margin-left: 2em ;
margin-right: 2em }

pre.code .ln { color: grey; } /* line numbers */
pre.code .ln { color: gray; } /* line numbers */
pre.code, code { background-color: #eeeeee }
pre.code .comment, code .comment { color: #5C6576 }
pre.code .keyword, code .keyword { color: #3B0D06; font-weight: bold }
Expand All @@ -300,7 +301,7 @@
span.pre {
white-space: pre }

span.problematic {
span.problematic, pre.problematic {
color: red }

span.section-subtitle {
Expand Down Expand Up @@ -402,12 +403,18 @@ <h2><a class="toc-backref" href="#toc-entry-3">Authors</a></h2>
<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>
<li>Carlos Roca</li>
</ul>
</li>
</ul>
</div>
<div class="section" id="maintainers">
<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" /></a>
<a class="reference external image-reference" href="https://odoo-community.org">
<img alt="Odoo Community Association" src="https://odoo-community.org/logo.png" />
</a>
<p>OCA, or the Odoo Community Association, is a nonprofit organization whose
mission is to support the collaborative development of Odoo features and
promote its widespread use.</p>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,39 @@
_inherit = "spreadsheet.spreadsheet.import"

dashboard_id = fields.Many2one("spreadsheet.dashboard")
dashboard_group_id = fields.Many2one("spreadsheet.dashboard.group")

def _create_spreadsheet_dashboard_vals(self):
return {

Check warning on line 15 in spreadsheet_dashboard_oca/wizards/spreadsheet_spreadsheet_import.py

View check run for this annotation

Codecov / codecov/patch

spreadsheet_dashboard_oca/wizards/spreadsheet_spreadsheet_import.py#L15

Added line #L15 was not covered by tests
"name": self.name,
"dashboard_group_id": self.dashboard_group_id.id,
}

def _insert_pivot_dashboard_spreadsheet(self):
dashboard = self.env["spreadsheet.dashboard"].create(

Check warning on line 21 in spreadsheet_dashboard_oca/wizards/spreadsheet_spreadsheet_import.py

View check run for this annotation

Codecov / codecov/patch

spreadsheet_dashboard_oca/wizards/spreadsheet_spreadsheet_import.py#L21

Added line #L21 was not covered by tests
self._create_spreadsheet_dashboard_vals()
)
import_data = self.import_data
import_data["name"] = self.datasource_name
import_data["new"] = 1

Check warning on line 26 in spreadsheet_dashboard_oca/wizards/spreadsheet_spreadsheet_import.py

View check run for this annotation

Codecov / codecov/patch

spreadsheet_dashboard_oca/wizards/spreadsheet_spreadsheet_import.py#L24-L26

Added lines #L24 - L26 were not covered by tests
if self.dynamic:
import_data["dyn_number_of_rows"] = self.number_of_rows
return {

Check warning on line 29 in spreadsheet_dashboard_oca/wizards/spreadsheet_spreadsheet_import.py

View check run for this annotation

Codecov / codecov/patch

spreadsheet_dashboard_oca/wizards/spreadsheet_spreadsheet_import.py#L28-L29

Added lines #L28 - L29 were not covered by tests
"type": "ir.actions.client",
"tag": "action_spreadsheet_oca",
"params": {
"model": dashboard._name,
"spreadsheet_id": dashboard.id,
"import_data": import_data,
},
}

def _insert_pivot_dashboard(self, new_sheet=False):
import_data = self.import_data
import_data["name"] = self.name
import_data["name"] = self.datasource_name

Check warning on line 41 in spreadsheet_dashboard_oca/wizards/spreadsheet_spreadsheet_import.py

View check run for this annotation

Codecov / codecov/patch

spreadsheet_dashboard_oca/wizards/spreadsheet_spreadsheet_import.py#L41

Added line #L41 was not covered by tests
import_data["new_sheet"] = new_sheet
if self.dynamic:
import_data["dyn_number_of_rows"] = self.number_of_rows

Check warning on line 44 in spreadsheet_dashboard_oca/wizards/spreadsheet_spreadsheet_import.py

View check run for this annotation

Codecov / codecov/patch

spreadsheet_dashboard_oca/wizards/spreadsheet_spreadsheet_import.py#L44

Added line #L44 was not covered by tests
return {
"type": "ir.actions.client",
"tag": "action_spreadsheet_oca",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,34 @@
ref="spreadsheet_oca.spreadsheet_spreadsheet_import_form_view"
/>
<field name="arch" type="xml">
<field name="name" position="attributes">
<attribute
name="attrs"
operation="attrs_domain_add"
key="invisible"
join_operator="AND"
>
[['mode', '!=', 'dashboard_spreadsheet']]
</attribute>
<attribute
name="attrs"
operation="attrs_domain_add"
key="required"
join_operator="OR"
>
[['mode', '=', 'dashboard_spreadsheet']]
</attribute>
</field>
<field name="spreadsheet_id" position="after">
<field
name="dashboard_id"
attrs="{'invisible': [('mode', '!=', 'dashboard')], 'required': [('mode', '=', 'dashboard')]}"
attrs="{'invisible': [('mode', 'not in', ['dashboard', 'dashboard_sheet'])], 'required': [('mode', 'in', ['dashboard', 'dashboard_sheet'])]}"
domain="[('can_edit', '=', True)]"
options="{'no_create': True}"
/>
<field
name="dashboard_group_id"
attrs="{'invisible': [('mode', '!=', 'dashboard_spreadsheet')], 'required': [('mode', '=', 'dashboard_spreadsheet')]}"
options="{'no_create': True}"
/>
</field>
Expand Down
Loading
Loading