Skip to content

Commit 4ba6790

Browse files
committed
[MIG] spreadsheet_oca: Migration to 18.0
1 parent c75e649 commit 4ba6790

18 files changed

+157
-194
lines changed

spreadsheet_oca/__manifest__.py

Lines changed: 8 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"name": "Spreadsheet Oca",
66
"summary": """
77
Allow to edit spreadsheets""",
8-
"version": "17.0.1.0.0",
8+
"version": "18.0.1.0.0",
99
"license": "AGPL-3",
1010
"author": "CreuBlanca,Odoo Community Association (OCA)",
1111
"website": "https://github.com/OCA/spreadsheet",
@@ -25,25 +25,15 @@
2525
"spreadsheet_oca/static/src/spreadsheet_tree/spreadsheet_tree_view.xml",
2626
"spreadsheet_oca/static/src/spreadsheet/spreadsheet.scss",
2727
"spreadsheet_oca/static/src/spreadsheet/spreadsheet_action.esm.js",
28-
"spreadsheet_oca/static/src/spreadsheet/pivot_controller.esm.js",
29-
"spreadsheet_oca/static/src/spreadsheet/graph_controller.esm.js",
3028
"spreadsheet_oca/static/src/spreadsheet/list_controller.esm.js",
3129
"spreadsheet_oca/static/src/spreadsheet/list_renderer.esm.js",
32-
(
33-
"after",
34-
"web/static/src/views/graph/graph_controller.xml",
35-
"spreadsheet_oca/static/src/spreadsheet/graph_controller.xml",
36-
),
37-
(
38-
"after",
39-
"web/static/src/views/list/list_controller.xml",
40-
"spreadsheet_oca/static/src/spreadsheet/list_controller.xml",
41-
),
42-
(
43-
"after",
44-
"web/static/src/views/pivot/pivot_controller.xml",
45-
"spreadsheet_oca/static/src/spreadsheet/pivot_controller.xml",
46-
),
30+
"spreadsheet_oca/static/src/spreadsheet/list_controller.xml",
31+
],
32+
"web.assets_backend_lazy": [
33+
"spreadsheet_oca/static/src/spreadsheet/pivot_controller.esm.js",
34+
"spreadsheet_oca/static/src/spreadsheet/graph_controller.esm.js",
35+
"spreadsheet_oca/static/src/spreadsheet/pivot_controller.xml",
36+
"spreadsheet_oca/static/src/spreadsheet/graph_controller.xml",
4737
],
4838
"spreadsheet.o_spreadsheet": [
4939
"spreadsheet_oca/static/src/spreadsheet/bundle/spreadsheet.xml",

spreadsheet_oca/migrations/17.0.1.0.0/pre-migrate.py

Lines changed: 0 additions & 17 deletions
This file was deleted.

spreadsheet_oca/models/spreadsheet_abstract.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,7 @@ def get_spreadsheet_data(self):
7676
self.ensure_one()
7777
mode = "normal"
7878
try:
79-
self.check_access_rights("write")
80-
self.check_access_rule("write")
79+
self.check_access("write")
8180
except AccessError:
8281
mode = "readonly"
8382
return {

spreadsheet_oca/static/description/index.html

Lines changed: 22 additions & 22 deletions
Large diffs are not rendered by default.

spreadsheet_oca/static/src/pivot/pivot_table.esm.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/** @odoo-module */
22
/* Copyright 2024 Tecnativa - Carlos Roca
33
* License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl). */
4-
import {SpreadsheetPivotTable} from "@spreadsheet/pivot/pivot_table";
4+
import {SpreadsheetPivotTable} from "@odoo/o-spreadsheet";
55
import {patch} from "@web/core/utils/patch";
66

77
patch(SpreadsheetPivotTable.prototype, {

spreadsheet_oca/static/src/spreadsheet/bundle/chart_panels.esm.js

Lines changed: 23 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,18 @@
22

33
import * as spreadsheet from "@odoo/o-spreadsheet";
44
import {Domain} from "@web/core/domain";
5-
65
import {Many2XAutocomplete} from "@web/views/fields/relational_utils";
6+
import {_t} from "@web/core/l10n/translation";
77
import {patch} from "@web/core/utils/patch";
88
import {useService} from "@web/core/utils/hooks";
9-
import {_t} from "@web/core/l10n/translation";
109

11-
const {LineBarPieConfigPanel, ScorecardChartConfigPanel, GaugeChartConfigPanel} =
12-
spreadsheet.components;
10+
const {
11+
GenericChartConfigPanel,
12+
LineConfigPanel,
13+
BarConfigPanel,
14+
ScorecardChartConfigPanel,
15+
GaugeChartConfigPanel,
16+
} = spreadsheet.components;
1317

1418
const menuChartProps = {
1519
setup() {
@@ -55,7 +59,6 @@ const menuChartProps = {
5559
return;
5660
}
5761
const menu = this.env.model.getters.getIrMenu(menuId[0].id);
58-
console.log(menu);
5962
this.env.model.dispatch("LINK_ODOO_MENU_TO_CHART", {
6063
chartId: this.props.figureId,
6164
odooMenuId: menu.xmlid || menu.id,
@@ -77,9 +80,21 @@ const menuChartProps = {
7780
},
7881
};
7982

80-
patch(LineBarPieConfigPanel.prototype, menuChartProps);
81-
LineBarPieConfigPanel.components = {
82-
...LineBarPieConfigPanel.components,
83+
patch(GenericChartConfigPanel.prototype, menuChartProps);
84+
GenericChartConfigPanel.components = {
85+
...GenericChartConfigPanel.components,
86+
Many2XAutocomplete,
87+
};
88+
89+
patch(LineConfigPanel.prototype, menuChartProps);
90+
LineConfigPanel.components = {
91+
...LineConfigPanel.components,
92+
Many2XAutocomplete,
93+
};
94+
95+
patch(BarConfigPanel.prototype, menuChartProps);
96+
BarConfigPanel.components = {
97+
...BarConfigPanel.components,
8398
Many2XAutocomplete,
8499
};
85100

spreadsheet_oca/static/src/spreadsheet/bundle/spreadsheet.xml

Lines changed: 6 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -320,6 +320,7 @@
320320
title="Change name"
321321
t-ref="spreadsheetName"
322322
t-att-value="state.name"
323+
t-att-readonly="props.isReadonly"
323324
t-on-change="_onNameChanged"
324325
/>
325326
<i class="fa fa-exclamation-triangle text-danger" t-if="! state.name" />
@@ -444,34 +445,6 @@
444445
</div>
445446

446447
<t t-slot="control-panel-status-indicator" />
447-
<!--<ol class="breadcrumb">
448-
<t t-foreach="breadcrumbs" t-as="breadcrumb" t-key="breadcrumb.jsId">
449-
<t
450-
t-set="isPenultimate"
451-
t-value="breadcrumb_index === breadcrumbs.length - 2"
452-
/>
453-
<li
454-
t-if="!breadcrumb_last"
455-
class="breadcrumb-item"
456-
t-att-data-hotkey="isPenultimate and 'b'"
457-
t-att-class="{ o_back_button: isPenultimate}"
458-
t-on-click.prevent="() => this.onBreadcrumbClicked(breadcrumb.jsId)"
459-
>
460-
<a href="#">
461-
<t t-if="breadcrumb.name" t-esc="breadcrumb.name" />
462-
<em t-else="" class="text-warning">Unnamed</em>
463-
</a>
464-
</li>
465-
466-
<li t-else="" class="breadcrumb-item active d-flex align-items-center">
467-
<SpreadsheetName
468-
name="props.record.name"
469-
isReadonly="false"
470-
onChanged="onSpreadsheetNameChanged"
471-
/>
472-
</li>
473-
</t>
474-
</ol>-->
475448
</t>
476449
<t t-name="spreadsheet_oca.PivotIcon" owl="1">
477450
<i class="fa fa-table" />
@@ -633,11 +606,7 @@
633606
</div>
634607
</xpath>
635608
</t>
636-
<t
637-
t-inherit="spreadsheet.o-spreadsheet-BarConfigPanel"
638-
t-inherit-mode="extension"
639-
owl="1"
640-
>
609+
<t t-inherit="o-spreadsheet-GenericChartConfigPanel" t-inherit-mode="extension">
641610
<xpath expr="//div" position="inside">
642611
<div class="o-section">
643612
<div class="o-section-title">Link to Odoo menu</div>
@@ -647,11 +616,7 @@
647616
</div>
648617
</xpath>
649618
</t>
650-
<t
651-
t-inherit="spreadsheet.o-spreadsheet-LineConfigPanel"
652-
t-inherit-mode="extension"
653-
owl="1"
654-
>
619+
<t t-inherit="o-spreadsheet-BarConfigPanel" t-inherit-mode="extension">
655620
<xpath expr="//div" position="inside">
656621
<div class="o-section">
657622
<div class="o-section-title">Link to Odoo menu</div>
@@ -661,11 +626,7 @@
661626
</div>
662627
</xpath>
663628
</t>
664-
<t
665-
t-inherit="spreadsheet.o-spreadsheet-LineBarPieConfigPanel"
666-
t-inherit-mode="extension"
667-
owl="1"
668-
>
629+
<t t-inherit="o-spreadsheet-LineConfigPanel" t-inherit-mode="extension">
669630
<xpath expr="//div" position="inside">
670631
<div class="o-section">
671632
<div class="o-section-title">Link to Odoo menu</div>
@@ -675,11 +636,7 @@
675636
</div>
676637
</xpath>
677638
</t>
678-
<t
679-
t-inherit="spreadsheet.o-spreadsheet-GaugeChartConfigPanel"
680-
t-inherit-mode="extension"
681-
owl="1"
682-
>
639+
<t t-inherit="o-spreadsheet-GaugeChartConfigPanel" t-inherit-mode="extension">
683640
<xpath expr="//div" position="inside">
684641
<div class="o-section">
685642
<div class="o-section-title">Link to Odoo menu</div>
@@ -689,11 +646,7 @@
689646
</div>
690647
</xpath>
691648
</t>
692-
<t
693-
t-inherit="spreadsheet.o-spreadsheet-ScorecardChartConfigPanel"
694-
t-inherit-mode="extension"
695-
owl="1"
696-
>
649+
<t t-inherit="o-spreadsheet-ScorecardChartConfigPanel" t-inherit-mode="extension">
697650
<xpath expr="//div" position="inside">
698651
<div class="o-section">
699652
<div class="o-section-title">Link to Odoo menu</div>

spreadsheet_oca/static/src/spreadsheet/bundle/spreadsheet_action.esm.js

Lines changed: 17 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -2,36 +2,30 @@
22

33
import * as spreadsheet from "@odoo/o-spreadsheet";
44
import {makeDynamicCols, makeDynamicRows} from "../utils/dynamic_generators.esm";
5-
import {ListDataSource} from "@spreadsheet/list/list_data_source";
6-
import {PivotDataSource} from "@spreadsheet/pivot/pivot_data_source";
75
import {SpreadsheetControlPanel} from "./spreadsheet_controlpanel.esm";
86
import {SpreadsheetRenderer} from "./spreadsheet_renderer.esm";
97
import {registry} from "@web/core/registry";
8+
import {standardActionServiceProps} from "@web/webclient/actions/action_service";
109
import {useService} from "@web/core/utils/hooks";
1110

11+
const {load} = spreadsheet;
12+
1213
const uuidGenerator = new spreadsheet.helpers.UuidGenerator();
1314
const actionRegistry = registry.category("actions");
14-
const {Component, onMounted, onWillStart, useSubEnv} = owl;
15+
const {Component, onWillStart, useSubEnv} = owl;
1516

1617
export class ActionSpreadsheetOca extends Component {
1718
setup() {
18-
this.router = useService("router");
1919
this.orm = useService("orm");
2020
this.notification = useService("notification");
2121
const params = this.props.action.params || this.props.action.context.params;
2222
this.spreadsheetId = params.spreadsheet_id;
2323
this.model = params.model || "spreadsheet.spreadsheet";
2424
this.import_data = params.import_data || {};
25-
onMounted(() => {
26-
this.router.pushState({
27-
spreadsheet_id: this.spreadsheetId,
28-
model: this.model,
29-
});
30-
});
3125
onWillStart(async () => {
3226
// We need to load in case the data comes from an XLSX
3327
this.record =
34-
spreadsheet.load(
28+
load(
3529
await this.orm.call(
3630
this.model,
3731
"get_spreadsheet_data",
@@ -46,6 +40,7 @@ export class ActionSpreadsheetOca extends Component {
4640
notifyUser: this.notifyUser.bind(this),
4741
});
4842
}
43+
4944
notifyUser(notification) {
5045
this.notification.add(notification.text, {
5146
type: notification.type,
@@ -60,7 +55,6 @@ export class ActionSpreadsheetOca extends Component {
6055
this.orm.call(this.model, "write", [this.spreadsheetId, data]);
6156
} else {
6257
this.spreadsheetId = await this.orm.call(this.model, "create", [data]);
63-
this.router.pushState({spreadsheet_id: this.spreadsheetId});
6458
}
6559
}
6660
/**
@@ -177,11 +171,11 @@ export class ActionSpreadsheetOca extends Component {
177171
},
178172
name: this.import_data.name,
179173
};
180-
const dataSource = spreadsheet_model.config.custom.dataSources.add(
181-
dataSourceId,
182-
ListDataSource,
183-
list_info
184-
);
174+
spreadsheet_model.dispatch("ADD_ODOO_LIST", {
175+
listId: dataSourceId,
176+
definition: list_info,
177+
});
178+
const dataSource = spreadsheet_model.getters.getListDataSource(dataSourceId);
185179
await dataSource.load();
186180
spreadsheet_model.dispatch("INSERT_ODOO_LIST", {
187181
sheetId,
@@ -222,11 +216,11 @@ export class ActionSpreadsheetOca extends Component {
222216
searchParams: this.cleanSearchParams(),
223217
name: this.import_data.name,
224218
};
225-
const dataSource = spreadsheet_model.config.custom.dataSources.add(
226-
dataSourceId,
227-
PivotDataSource,
228-
pivot_info
229-
);
219+
spreadsheet_model.dispatch("ADD_PIVOT", {
220+
pivotId: dataSourceId,
221+
definition: pivot_info,
222+
});
223+
const dataSource = spreadsheet_model.getters.getPivotDataSource(dataSourceId);
230224
await dataSource.load();
231225
var {cols, rows, measures} = dataSource.getTableStructure().export();
232226
if (this.import_data.dyn_number_of_rows) {
@@ -286,6 +280,7 @@ ActionSpreadsheetOca.components = {
286280
SpreadsheetRenderer,
287281
SpreadsheetControlPanel,
288282
};
283+
ActionSpreadsheetOca.props = {...standardActionServiceProps};
289284
actionRegistry.add("action_spreadsheet_oca", ActionSpreadsheetOca, {
290285
force: true,
291286
});

spreadsheet_oca/static/src/spreadsheet/bundle/spreadsheet_controlpanel.esm.js

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import {Component} from "@odoo/owl";
44
import {ControlPanel} from "@web/search/control_panel/control_panel";
5+
import {useService} from "@web/core/utils/hooks";
56

67
const {useState} = owl;
78

@@ -12,15 +13,35 @@ export class SpreadsheetName extends Component {
1213
});
1314
}
1415
_onNameChanged(ev) {
16+
if (this.props.isReadonly) {
17+
return;
18+
}
1519
if (ev.target.value) {
1620
this.env.saveRecord({name: ev.target.value});
1721
}
1822
this.state.name = ev.target.value;
23+
if (this.props.onChanged) {
24+
this.props.onChanged(ev);
25+
}
1926
}
2027
}
2128
SpreadsheetName.template = "spreadsheet_oca.SpreadsheetName";
29+
SpreadsheetName.props = {
30+
name: String,
31+
isReadonly: Boolean,
32+
onChanged: {type: Function, optional: true},
33+
};
34+
35+
export class SpreadsheetControlPanel extends ControlPanel {
36+
setup() {
37+
super.setup();
38+
this.actionService = useService("action");
39+
}
2240

23-
export class SpreadsheetControlPanel extends ControlPanel {}
41+
onBreadcrumbClicked(jsId) {
42+
this.actionService.restore(jsId);
43+
}
44+
}
2445
SpreadsheetControlPanel.template = "spreadsheet_oca.SpreadsheetControlPanel";
2546
SpreadsheetControlPanel.props = {
2647
...ControlPanel.props,

0 commit comments

Comments
 (0)