Skip to content

Commit

Permalink
[MIG] spreadsheet_oca: Continue migration
Browse files Browse the repository at this point in the history
  • Loading branch information
etobella committed Feb 16, 2025
1 parent f99ac01 commit 1b4cf23
Show file tree
Hide file tree
Showing 15 changed files with 447 additions and 270 deletions.
120 changes: 61 additions & 59 deletions spreadsheet_oca/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -45,93 +45,95 @@ Usage
**Create a new spreadsheet**
----------------------------

- Go to 'Spreadsheet' menu
- Click on 'Create'
- Put a name, then click on the "Edit" button
- Go to 'Spreadsheet' menu
- Click on 'Create'
- Put a name, then click on the "Edit" button

|image0|

- At this point you switch to spreadsheet editing mode. The editor is
named ``o-spreadsheet`` and looks like another common spreadsheet web
editors. (OnlyOffice, Ethercalc, Google Sheets (non-free)).

|image1|

- At this point you switch to spreadsheet editing mode. The editor is
named ``o-spreadsheet`` and looks like another common spreadsheet web
editors. (OnlyOffice, Ethercalc, Google Sheets (non-free)).
- You can use common functions ``SUM()``, ``AVERAGE()``, etc. in the
cells. For a complete list of functions and their syntax, Refer to
the documentation
`https://github.com/odoo/o-spreadsheet/ <https://github.com/odoo/o-spreadsheet/>`__
or go to
`https://odoo.github.io/o-spreadsheet/ <https://odoo.github.io/o-spreadsheet/>`__
and click on "Insert > Function".

|image2|

- You can use common functions ``SUM()``, ``AVERAGE()``, etc. in the
cells. For a complete list of functions and their syntax, Refer to the
documentation https://github.com/odoo/o-spreadsheet/ or go to
https://odoo.github.io/o-spreadsheet/ and click on "Insert >
Function".

|image3|

- Note: Business Odoo module can add "business functions". This is
currently the case for the accounting module, which adds the following
features:

- ``ODOO.CREDIT(account_codes, date_range)``: Get the total credit
for the specified account(s) and period.
- ``ODOO.DEBIT(account_codes, date_range)``: Get the total debit
for the specified account(s) and period.
- ``ODOO.BALANCE(account_codes, date_range)``: Get the total
balance for the specified account(s) and period.
- ``ODOO.FISCALYEAR.START(day)``: Returns the starting date of the
fiscal year encompassing the provided date.
- ``ODOO.FISCALYEAR.END(day)``: Returns the ending date of the
fiscal year encompassing the provided date.
- ``ODOO.ACCOUNT.GROUP(type)``: Returns the account ids of a given
group where type should be a value of the ``account_type`` field
of ``account.account`` model. (``income``, ``asset_receivable``,
etc.)
- Note: Business Odoo module can add "business functions". This is
currently the case for the accounting module, which adds the
following features:

- ``ODOO.CREDIT(account_codes, date_range)``: Get the total
credit for the specified account(s) and period.
- ``ODOO.DEBIT(account_codes, date_range)``: Get the total debit
for the specified account(s) and period.
- ``ODOO.BALANCE(account_codes, date_range)``: Get the total
balance for the specified account(s) and period.
- ``ODOO.FISCALYEAR.START(day)``: Returns the starting date of
the fiscal year encompassing the provided date.
- ``ODOO.FISCALYEAR.END(day)``: Returns the ending date of the
fiscal year encompassing the provided date.
- ``ODOO.ACCOUNT.GROUP(type)``: Returns the account ids of a
given group where type should be a value of the
``account_type`` field of ``account.account`` model.
(``income``, ``asset_receivable``, etc.)

**Create a new dynamic spreadsheet from pivot**
-----------------------------------------------

- Go to any pivot
- Press on insert button
- Select the dynamic rows or dynamic columns option and set a number of
rows/columns
- Go to any pivot
- Press on insert button
- Select the dynamic rows or dynamic columns option and set a number of
rows/columns

A new table that will be updated with the actual or filtered values will
be added.

- Note: When a pivot has multiple levels of aggrupations in the rows or
the columns, the number of rows/columns selected will be transfered to
each level.
- Note: When a pivot has multiple levels of aggrupations in the rows or
the columns, the number of rows/columns selected will be transfered
to each level.

Example: number of groups -> 2 number of rows -> 3
Example: number of groups -> 2 number of rows -> 3

- val1
- val1

- subval1.1
- subval1.2
- subval1.3
- subval1.1
- subval1.2
- subval1.3

- val2
- val2

- subval2.1
- subval2.2
- subval2.3
- subval2.1
- subval2.2
- subval2.3

- val3
- val3

- subval3.1
- subval3.2
- subval3.3
- subval3.1
- subval3.2
- subval3.3

https://raw.githubusercontent.com/OCA/spreadsheet/17.0/spreadsheet_oca/Hhttps://raw.githubusercontent.com/OCA/spreadsheet/17.0/spreadsheet_oca/ehttps://raw.githubusercontent.com/OCA/spreadsheet/17.0/spreadsheet_oca/rhttps://raw.githubusercontent.com/OCA/spreadsheet/17.0/spreadsheet_oca/ehttps://raw.githubusercontent.com/OCA/spreadsheet/17.0/spreadsheet_oca/ https://raw.githubusercontent.com/OCA/spreadsheet/17.0/spreadsheet_oca/ihttps://raw.githubusercontent.com/OCA/spreadsheet/17.0/spreadsheet_oca/shttps://raw.githubusercontent.com/OCA/spreadsheet/17.0/spreadsheet_oca/ https://raw.githubusercontent.com/OCA/spreadsheet/17.0/spreadsheet_oca/ahttps://raw.githubusercontent.com/OCA/spreadsheet/17.0/spreadsheet_oca/ https://raw.githubusercontent.com/OCA/spreadsheet/17.0/spreadsheet_oca/vhttps://raw.githubusercontent.com/OCA/spreadsheet/17.0/spreadsheet_oca/ihttps://raw.githubusercontent.com/OCA/spreadsheet/17.0/spreadsheet_oca/shttps://raw.githubusercontent.com/OCA/spreadsheet/17.0/spreadsheet_oca/uhttps://raw.githubusercontent.com/OCA/spreadsheet/17.0/spreadsheet_oca/ahttps://raw.githubusercontent.com/OCA/spreadsheet/17.0/spreadsheet_oca/lhttps://raw.githubusercontent.com/OCA/spreadsheet/17.0/spreadsheet_oca/ https://raw.githubusercontent.com/OCA/spreadsheet/17.0/spreadsheet_oca/ehttps://raw.githubusercontent.com/OCA/spreadsheet/17.0/spreadsheet_oca/xhttps://raw.githubusercontent.com/OCA/spreadsheet/17.0/spreadsheet_oca/ahttps://raw.githubusercontent.com/OCA/spreadsheet/17.0/spreadsheet_oca/phttps://raw.githubusercontent.com/OCA/spreadsheet/17.0/spreadsheet_oca/lhttps://raw.githubusercontent.com/OCA/spreadsheet/17.0/spreadsheet_oca/ehttps://raw.githubusercontent.com/OCA/spreadsheet/17.0/spreadsheet_oca/ https://raw.githubusercontent.com/OCA/spreadsheet/17.0/spreadsheet_oca/ohttps://raw.githubusercontent.com/OCA/spreadsheet/17.0/spreadsheet_oca/fhttps://raw.githubusercontent.com/OCA/spreadsheet/17.0/spreadsheet_oca/ https://raw.githubusercontent.com/OCA/spreadsheet/17.0/spreadsheet_oca/uhttps://raw.githubusercontent.com/OCA/spreadsheet/17.0/spreadsheet_oca/shttps://raw.githubusercontent.com/OCA/spreadsheet/17.0/spreadsheet_oca/ehttps://raw.githubusercontent.com/OCA/spreadsheet/17.0/spreadsheet_oca/:https://raw.githubusercontent.com/OCA/spreadsheet/17.0/spreadsheet_oca/ https://raw.githubusercontent.com/OCA/spreadsheet/17.0/spreadsheet_oca/.https://raw.githubusercontent.com/OCA/spreadsheet/17.0/spreadsheet_oca/.https://raw.githubusercontent.com/OCA/spreadsheet/17.0/spreadsheet_oca/ https://raw.githubusercontent.com/OCA/spreadsheet/17.0/spreadsheet_oca/fhttps://raw.githubusercontent.com/OCA/spreadsheet/17.0/spreadsheet_oca/ihttps://raw.githubusercontent.com/OCA/spreadsheet/17.0/spreadsheet_oca/ghttps://raw.githubusercontent.com/OCA/spreadsheet/17.0/spreadsheet_oca/uhttps://raw.githubusercontent.com/OCA/spreadsheet/17.0/spreadsheet_oca/rhttps://raw.githubusercontent.com/OCA/spreadsheet/17.0/spreadsheet_oca/ehttps://raw.githubusercontent.com/OCA/spreadsheet/17.0/spreadsheet_oca/:https://raw.githubusercontent.com/OCA/spreadsheet/17.0/spreadsheet_oca/:https://raw.githubusercontent.com/OCA/spreadsheet/17.0/spreadsheet_oca/
https://raw.githubusercontent.com/OCA/spreadsheet/17.0/spreadsheet_oca/../static/description/spreadsheetdynamic_table.gif

.. |image1| image:: https://raw.githubusercontent.com/OCA/spreadsheet/17.0/spreadsheet_oca/static/description/spreadsheet_create.png
.. |image2| image:: https://raw.githubusercontent.com/OCA/spreadsheet/17.0/spreadsheet_oca/static/description/spreadsheet_edit.png
.. |image3| image:: https://raw.githubusercontent.com/OCA/spreadsheet/17.0/spreadsheet_oca/static/description/o-spreadsheet.png
.. |image0| image:: https://raw.githubusercontent.com/OCA/spreadsheet/17.0/spreadsheet_oca/static/description/spreadsheet_create.png
.. |image1| image:: https://raw.githubusercontent.com/OCA/spreadsheet/17.0/spreadsheet_oca/static/description/spreadsheet_edit.png
.. |image2| image:: https://raw.githubusercontent.com/OCA/spreadsheet/17.0/spreadsheet_oca/static/description/o-spreadsheet.png

Development
===========

If you want to develop custom business functions, you can add others,
based on the file
https://github.com/odoo/odoo/blob/16.0/addons/spreadsheet_account/static/src/accounting_functions.js
`https://github.com/odoo/odoo/blob/16.0/addons/spreadsheet_account/static/src/accounting_functions.js <https://github.com/odoo/odoo/blob/16.0/addons/spreadsheet_account/static/src/accounting_functions.js>`__

Known issues / Roadmap
======================
Expand Down Expand Up @@ -165,10 +167,10 @@ Authors
Contributors
------------

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

- Carlos Roca
- Carlos Roca

Maintainers
-----------
Expand Down
40 changes: 21 additions & 19 deletions spreadsheet_oca/static/description/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -405,41 +405,43 @@ <h2><a class="toc-backref" href="#toc-entry-2"><strong>Create a new spreadsheet<
<li>Click on ‘Create’</li>
<li>Put a name, then click on the “Edit” button</li>
</ul>
<p><img alt="image1" src="https://raw.githubusercontent.com/OCA/spreadsheet/17.0/spreadsheet_oca/static/description/spreadsheet_create.png" /></p>
<p><img alt="image0" src="https://raw.githubusercontent.com/OCA/spreadsheet/17.0/spreadsheet_oca/static/description/spreadsheet_create.png" /></p>
<ul class="simple">
<li>At this point you switch to spreadsheet editing mode. The editor is
named <tt class="docutils literal"><span class="pre">o-spreadsheet</span></tt> and looks like another common spreadsheet web
editors. (OnlyOffice, Ethercalc, Google Sheets (non-free)).</li>
</ul>
<p><img alt="image2" src="https://raw.githubusercontent.com/OCA/spreadsheet/17.0/spreadsheet_oca/static/description/spreadsheet_edit.png" /></p>
<p><img alt="image1" src="https://raw.githubusercontent.com/OCA/spreadsheet/17.0/spreadsheet_oca/static/description/spreadsheet_edit.png" /></p>
<ul class="simple">
<li>You can use common functions <tt class="docutils literal">SUM()</tt>, <tt class="docutils literal">AVERAGE()</tt>, etc. in the
cells. For a complete list of functions and their syntax, Refer to the
documentation <a class="reference external" href="https://github.com/odoo/o-spreadsheet/">https://github.com/odoo/o-spreadsheet/</a> or go to
<a class="reference external" href="https://odoo.github.io/o-spreadsheet/">https://odoo.github.io/o-spreadsheet/</a> and click on “Insert &gt;
Function”.</li>
cells. For a complete list of functions and their syntax, Refer to
the documentation
<a class="reference external" href="https://github.com/odoo/o-spreadsheet/">https://github.com/odoo/o-spreadsheet/</a>
or go to
<a class="reference external" href="https://odoo.github.io/o-spreadsheet/">https://odoo.github.io/o-spreadsheet/</a>
and click on “Insert &gt; Function”.</li>
</ul>
<p><img alt="image3" src="https://raw.githubusercontent.com/OCA/spreadsheet/17.0/spreadsheet_oca/static/description/o-spreadsheet.png" /></p>
<p><img alt="image2" src="https://raw.githubusercontent.com/OCA/spreadsheet/17.0/spreadsheet_oca/static/description/o-spreadsheet.png" /></p>
<ul>
<li><p class="first">Note: Business Odoo module can add “business functions”. This is
currently the case for the accounting module, which adds the following
features:</p>
currently the case for the accounting module, which adds the
following features:</p>
<blockquote>
<ul class="simple">
<li><tt class="docutils literal">ODOO.CREDIT(account_codes, date_range)</tt>: Get the total credit
for the specified account(s) and period.</li>
<li><tt class="docutils literal">ODOO.CREDIT(account_codes, date_range)</tt>: Get the total
credit for the specified account(s) and period.</li>
<li><tt class="docutils literal">ODOO.DEBIT(account_codes, date_range)</tt>: Get the total debit
for the specified account(s) and period.</li>
<li><tt class="docutils literal">ODOO.BALANCE(account_codes, date_range)</tt>: Get the total
balance for the specified account(s) and period.</li>
<li><tt class="docutils literal">ODOO.FISCALYEAR.START(day)</tt>: Returns the starting date of the
fiscal year encompassing the provided date.</li>
<li><tt class="docutils literal">ODOO.FISCALYEAR.START(day)</tt>: Returns the starting date of
the fiscal year encompassing the provided date.</li>
<li><tt class="docutils literal">ODOO.FISCALYEAR.END(day)</tt>: Returns the ending date of the
fiscal year encompassing the provided date.</li>
<li><tt class="docutils literal">ODOO.ACCOUNT.GROUP(type)</tt>: Returns the account ids of a given
group where type should be a value of the <tt class="docutils literal">account_type</tt> field
of <tt class="docutils literal">account.account</tt> model. (<tt class="docutils literal">income</tt>, <tt class="docutils literal">asset_receivable</tt>,
etc.)</li>
<li><tt class="docutils literal">ODOO.ACCOUNT.GROUP(type)</tt>: Returns the account ids of a
given group where type should be a value of the
<tt class="docutils literal">account_type</tt> field of <tt class="docutils literal">account.account</tt> model.
(<tt class="docutils literal">income</tt>, <tt class="docutils literal">asset_receivable</tt>, etc.)</li>
</ul>
</blockquote>
</li>
Expand All @@ -457,8 +459,8 @@ <h2><a class="toc-backref" href="#toc-entry-3"><strong>Create a new dynamic spre
be added.</p>
<ul>
<li><p class="first">Note: When a pivot has multiple levels of aggrupations in the rows or
the columns, the number of rows/columns selected will be transfered to
each level.</p>
the columns, the number of rows/columns selected will be transfered
to each level.</p>
<p>Example: number of groups -&gt; 2 number of rows -&gt; 3</p>
<ul class="simple">
<li>val1<ul>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ patch(ChartPanel.prototype, {
sheetId: this.env.model.getters.getActiveSheetId(),
});
} else {
this._super(type);
super.onTypeChange(type);
}
},
});
37 changes: 31 additions & 6 deletions spreadsheet_oca/static/src/spreadsheet/bundle/chart_panels.esm.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@

import * as spreadsheet from "@odoo/o-spreadsheet";
import {Domain} from "@web/core/domain";
import {Many2OneField} from "@web/views/fields/many2one/many2one_field";

import {Many2XAutocomplete} from "@web/views/fields/relational_utils";
import {patch} from "@web/core/utils/patch";
import {useService} from "@web/core/utils/hooks";

Expand All @@ -11,9 +12,32 @@ const {LineBarPieConfigPanel, ScorecardChartConfigPanel, GaugeChartConfigPanel}

const menuChartProps = {
setup() {
this._super.apply(this, arguments);
super.setup(...arguments);
this.menus = useService("menu");
},
get menuProps() {
const menu = this.env.model.getters.getChartOdooMenu(this.props.figureId);
var result = {
record: this.record,
resModel: "ir.ui.menu",
update: this.updateMenu.bind(this),
activeActions: {},
getDomain: this.getDomain.bind(this),
};
if (menu) {
result.value = menu.name;
result.id = menu.id;
}
return result;
},

getDomain() {
const menus = this.menus
.getAll()
.map((menu) => menu.id)
.filter((menuId) => menuId !== "root");
return [["id", "in", menus]];
},
get menuId() {
const menu = this.env.model.getters.getChartOdooMenu(this.props.figureId);
if (menu) {
Expand All @@ -29,7 +53,8 @@ const menuChartProps = {
});
return;
}
const menu = this.env.model.getters.getIrMenu(menuId[0]);
const menu = this.env.model.getters.getIrMenu(menuId[0].id);
console.log(menu);
this.env.model.dispatch("LINK_ODOO_MENU_TO_CHART", {
chartId: this.props.figureId,
odooMenuId: menu.xmlid || menu.id,
Expand All @@ -54,17 +79,17 @@ const menuChartProps = {
patch(LineBarPieConfigPanel.prototype, menuChartProps);
LineBarPieConfigPanel.components = {
...LineBarPieConfigPanel.components,
Many2OneField,
Many2XAutocomplete,
};

patch(ScorecardChartConfigPanel.prototype, menuChartProps);
ScorecardChartConfigPanel.components = {
...ScorecardChartConfigPanel.components,
Many2OneField,
Many2XAutocomplete,
};

patch(GaugeChartConfigPanel.prototype, menuChartProps);
GaugeChartConfigPanel.components = {
...GaugeChartConfigPanel.components,
Many2OneField,
Many2XAutocomplete,
};
8 changes: 4 additions & 4 deletions spreadsheet_oca/static/src/spreadsheet/bundle/filter.esm.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,18 @@ topbarMenuRegistry.add("file", {name: _t("File"), sequence: 10});
topbarMenuRegistry.addChild("filters", ["file"], {
name: _t("Filters"),
sequence: 70,
action: (env) => env.openSidePanel("FilterPanel", {}),
execute: (env) => env.openSidePanel("FilterPanel", {}),
});
topbarMenuRegistry.addChild("save", ["file"], {
name: _t("Save"),
// Description: "Ctrl+S", // This is not working, so removing it from the view for now...
sequence: 10,
action: (env) => env.saveSpreadsheet(),
execute: (env) => env.saveSpreadsheet(),
});
topbarMenuRegistry.addChild("download", ["file"], {
name: _t("Download XLSX"),
sequence: 20,
action: (env) => env.downloadAsXLXS(),
execute: (env) => env.downloadAsXLXS(),
});

const {sidePanelRegistry} = spreadsheet.registries;
Expand Down Expand Up @@ -77,7 +77,7 @@ export class EditFilterPanel extends Component {
}
var ModelFields = [];
for (var [objectType, objectClass] of Object.entries(globalFiltersFieldMatchers)) {
for (const objectId of objectClass.geIds()) {
for (const objectId of objectClass.getIds()) {
var fields = objectClass.getFields(objectId);
this.state.objects[objectType + "_" + objectId] = {
id: objectType + "_" + objectId,
Expand Down
Loading

0 comments on commit 1b4cf23

Please sign in to comment.