diff --git a/addons/base_import/static/src/import_action/import_action.xml b/addons/base_import/static/src/import_action/import_action.xml index e5e4420a5a9..1c8958fcbfc 100644 --- a/addons/base_import/static/src/import_action/import_action.xml +++ b/addons/base_import/static/src/import_action/import_action.xml @@ -3,7 +3,7 @@
- + diff --git a/addons/calendar/static/src/views/attendee_calendar/attendee_calendar_controller.xml b/addons/calendar/static/src/views/attendee_calendar/attendee_calendar_controller.xml index cef61afbe2e..e4c6d8caf7f 100644 --- a/addons/calendar/static/src/views/attendee_calendar/attendee_calendar_controller.xml +++ b/addons/calendar/static/src/views/attendee_calendar/attendee_calendar_controller.xml @@ -20,13 +20,10 @@
-
- - - - + + - + diff --git a/addons/calendar/static/src/views/attendee_calendar/attendee_calendar_view.js b/addons/calendar/static/src/views/attendee_calendar/attendee_calendar_view.js index 96f6b793611..3d3f47f21a9 100644 --- a/addons/calendar/static/src/views/attendee_calendar/attendee_calendar_view.js +++ b/addons/calendar/static/src/views/attendee_calendar/attendee_calendar_view.js @@ -11,7 +11,6 @@ export const attendeeCalendarView = { Controller: AttendeeCalendarController, Model: AttendeeCalendarModel, Renderer: AttendeeCalendarRenderer, - buttonTemplate: "calendar.AttendeeCalendarController.controlButtons", }; registry.category("views").add("attendee_calendar", attendeeCalendarView); diff --git a/addons/hr_holidays/static/src/views/calendar/calendar_controller.js b/addons/hr_holidays/static/src/views/calendar/calendar_controller.js index 40030311ec3..3cd97792353 100644 --- a/addons/hr_holidays/static/src/views/calendar/calendar_controller.js +++ b/addons/hr_holidays/static/src/views/calendar/calendar_controller.js @@ -111,7 +111,6 @@ export class TimeOffCalendarController extends CalendarController { }); } } -TimeOffCalendarController.template = "hr_holidays.CalendarController"; TimeOffCalendarController.components = { ...TimeOffCalendarController.components, FilterPanel: TimeOffCalendarFilterPanel, diff --git a/addons/hr_holidays/static/src/views/calendar/calendar_controller.xml b/addons/hr_holidays/static/src/views/calendar/calendar_controller.xml index 5a3db4ea95c..300f34702cf 100644 --- a/addons/hr_holidays/static/src/views/calendar/calendar_controller.xml +++ b/addons/hr_holidays/static/src/views/calendar/calendar_controller.xml @@ -1,12 +1,8 @@ - - - - - + + +
@@ -24,45 +33,6 @@
- -
- - - - - - - - - - April 2023 - - -
-
+
diff --git a/addons/web/static/src/views/calendar/calendar_year/calendar_year_renderer.js b/addons/web/static/src/views/calendar/calendar_year/calendar_year_renderer.js index cc298a597b3..46fb79f3aae 100644 --- a/addons/web/static/src/views/calendar/calendar_year/calendar_year_renderer.js +++ b/addons/web/static/src/views/calendar/calendar_year/calendar_year_renderer.js @@ -1,13 +1,12 @@ /** @odoo-module **/ -import { formatDate } from "@web/core/l10n/dates"; import { localization } from "@web/core/l10n/localization"; import { useDebounced } from "@web/core/utils/timing"; import { getColor } from "../colors"; import { useCalendarPopover, useFullCalendar } from "../hooks"; import { CalendarYearPopover } from "./calendar_year_popover"; -import { Component, useEffect, useRef, onRendered } from "@odoo/owl"; +import { Component, useEffect, useRef } from "@odoo/owl"; export class CalendarYearRenderer extends Component { setup() { @@ -26,11 +25,6 @@ export class CalendarYearRenderer extends Component { useEffect(() => { this.updateSize(); }); - - onRendered(() => { - const year = formatDate(this.props.model.date, { format: "yyyy" }); - this.env.config.setDisplayName(`${this.props.displayName} (${year})`); - }); } get options() { diff --git a/addons/web/static/src/views/graph/graph_controller.js b/addons/web/static/src/views/graph/graph_controller.js index 477fc9f0a20..9621003f943 100644 --- a/addons/web/static/src/views/graph/graph_controller.js +++ b/addons/web/static/src/views/graph/graph_controller.js @@ -1,8 +1,5 @@ /** @odoo-module **/ -import { Dropdown } from "@web/core/dropdown/dropdown"; -import { DropdownItem } from "@web/core/dropdown/dropdown_item"; -import { useService } from "@web/core/utils/hooks"; import { Layout } from "@web/search/layout"; import { GroupByMenu } from "@web/search/group_by_menu/group_by_menu"; import { useModel } from "@web/views/model"; @@ -14,7 +11,6 @@ import { Component, useRef } from "@odoo/owl"; export class GraphController extends Component { setup() { - this.actionService = useService("action"); this.model = useModel(this.props.Model, this.props.modelParams); useSetupView({ @@ -46,90 +42,10 @@ export class GraphController extends Component { } return context; } - - /** - * Execute the action to open the view on the current model. - * - * @param {Array} domain - * @param {Array} views - * @param {Object} context - */ - openView(domain, views, context) { - this.actionService.doAction( - { - context, - domain, - name: this.model.metaData.title, - res_model: this.model.metaData.resModel, - target: "current", - type: "ir.actions.act_window", - views, - }, - { - viewType: "list", - } - ); - } - /** - * @param {string} domain the domain of the clicked area - */ - onGraphClicked(domain) { - const { context } = this.model.metaData; - - Object.keys(context).forEach((x) => { - if (x === "group_by" || x.startsWith("search_default_")) { - delete context[x]; - } - }); - - const views = {}; - for (const [viewId, viewType] of this.env.config.views || []) { - views[viewType] = viewId; - } - function getView(viewType) { - return [views[viewType] || false, viewType]; - } - const actionViews = [getView("list"), getView("form")]; - this.openView(domain, actionViews, context); - } - - /** - * @param {Object} param0 - * @param {string} param0.measure - */ - onMeasureSelected({ measure }) { - this.model.updateMetaData({ measure }); - } - - /** - * @param {"bar"|"line"|"pie"} mode - */ - onModeSelected(mode) { - this.model.updateMetaData({ mode }); - } - - /** - * @param {"ASC"|"DESC"} order - */ - toggleOrder(order) { - const { order: currentOrder } = this.model.metaData; - const nextOrder = currentOrder === order ? null : order; - this.model.updateMetaData({ order: nextOrder }); - } - - toggleStacked() { - const { stacked } = this.model.metaData; - this.model.updateMetaData({ stacked: !stacked }); - } - - toggleCumulated() { - const { cumulated } = this.model.metaData; - this.model.updateMetaData({ cumulated: !cumulated }); - } } GraphController.template = "web.GraphView"; -GraphController.components = { Dropdown, DropdownItem, Layout, GroupByMenu, SearchBar }; +GraphController.components = { Layout, GroupByMenu, SearchBar }; GraphController.props = { ...standardViewProps, diff --git a/addons/web/static/src/views/graph/graph_controller.xml b/addons/web/static/src/views/graph/graph_controller.xml index dfba18b78c1..d5a9bcd9eef 100644 --- a/addons/web/static/src/views/graph/graph_controller.xml +++ b/addons/web/static/src/views/graph/graph_controller.xml @@ -53,9 +53,6 @@
- - - @@ -63,7 +60,7 @@ - + Invalid data diff --git a/addons/web/static/src/views/graph/graph_renderer.js b/addons/web/static/src/views/graph/graph_renderer.js index 98c0b1d227a..4aeec4c868f 100644 --- a/addons/web/static/src/views/graph/graph_renderer.js +++ b/addons/web/static/src/views/graph/graph_renderer.js @@ -10,6 +10,8 @@ import { renderToString } from "@web/core/utils/render"; import { useService } from "@web/core/utils/hooks"; import { Component, onWillUnmount, useEffect, useRef, onWillStart } from "@odoo/owl"; +import { Dropdown } from "@web/core/dropdown/dropdown"; +import { DropdownItem } from "@web/core/dropdown/dropdown_item"; const NO_DATA = _lt("No data"); @@ -49,6 +51,7 @@ export class GraphRenderer extends Component { this.canvasRef = useRef("canvas"); this.containerRef = useRef("container"); this.cookies = useService("cookie"); + this.actionService = useService("action"); this.chart = null; this.tooltip = null; @@ -450,15 +453,8 @@ export class GraphRenderer extends Component { * @returns {Object} */ getScaleOptions() { - const { - allIntegers, - fields, - groupBy, - measure, - measures, - mode, - stacked, - } = this.model.metaData; + const { allIntegers, fields, groupBy, measure, measures, mode, stacked } = + this.model.metaData; if (mode === "pie") { return {}; } @@ -558,7 +554,7 @@ export class GraphRenderer extends Component { const { _datasetIndex, _index } = activeElement; const { domains } = this.chart.data.datasets[_datasetIndex]; if (domains) { - this.props.onGraphClicked(domains[_index]); + this.onGraphClickedFinal(domains[_index]); } } @@ -674,7 +670,88 @@ export class GraphRenderer extends Component { // advancing the animation service. Chart.animationService.advance(); } + + /** + * Execute the action to open the view on the current model. + * + * @param {Array} domain + * @param {Array} views + * @param {Object} context + */ + openView(domain, views, context) { + this.actionService.doAction( + { + context, + domain, + name: this.model.metaData.title, + res_model: this.model.metaData.resModel, + target: "current", + type: "ir.actions.act_window", + views, + }, + { + viewType: "list", + } + ); + } + /** + * @param {string} domain the domain of the clicked area + */ + onGraphClickedFinal(domain) { + const { context } = this.model.metaData; + + Object.keys(context).forEach((x) => { + if (x === "group_by" || x.startsWith("search_default_")) { + delete context[x]; + } + }); + + const views = {}; + for (const [viewId, viewType] of this.env.config.views || []) { + views[viewType] = viewId; + } + function getView(viewType) { + return [views[viewType] || false, viewType]; + } + const actionViews = [getView("list"), getView("form")]; + this.openView(domain, actionViews, context); + } + + /** + * @param {Object} param0 + * @param {string} param0.measure + */ + onMeasureSelected({ measure }) { + this.model.updateMetaData({ measure }); + } + + /** + * @param {"bar"|"line"|"pie"} mode + */ + onModeSelected(mode) { + this.model.updateMetaData({ mode }); + } + + /** + * @param {"ASC"|"DESC"} order + */ + toggleOrder(order) { + const { order: currentOrder } = this.model.metaData; + const nextOrder = currentOrder === order ? null : order; + this.model.updateMetaData({ order: nextOrder }); + } + + toggleStacked() { + const { stacked } = this.model.metaData; + this.model.updateMetaData({ stacked: !stacked }); + } + + toggleCumulated() { + const { cumulated } = this.model.metaData; + this.model.updateMetaData({ cumulated: !cumulated }); + } } GraphRenderer.template = "web.GraphRenderer"; -GraphRenderer.props = ["class?", "model", "onGraphClicked"]; +GraphRenderer.components = { Dropdown, DropdownItem }; +GraphRenderer.props = ["class?", "model", "buttonTemplate"]; diff --git a/addons/web/static/src/views/graph/graph_renderer.xml b/addons/web/static/src/views/graph/graph_renderer.xml index ea324d3e947..6bb1f82e27f 100644 --- a/addons/web/static/src/views/graph/graph_renderer.xml +++ b/addons/web/static/src/views/graph/graph_renderer.xml @@ -28,8 +28,11 @@ -
-
+
+
+ +
+
diff --git a/addons/web/static/src/views/kanban/kanban_controller.xml b/addons/web/static/src/views/kanban/kanban_controller.xml index 8a202fb8e41..7edac28271d 100644 --- a/addons/web/static/src/views/kanban/kanban_controller.xml +++ b/addons/web/static/src/views/kanban/kanban_controller.xml @@ -10,7 +10,10 @@ New - + + + + - - - diff --git a/addons/web/static/src/views/list/list_controller.xml b/addons/web/static/src/views/list/list_controller.xml index e94e10b3017..4cd336c90ea 100644 --- a/addons/web/static/src/views/list/list_controller.xml +++ b/addons/web/static/src/views/list/list_controller.xml @@ -12,6 +12,9 @@ + + + - - - - diff --git a/addons/web/static/src/views/pivot/pivot_controller.js b/addons/web/static/src/views/pivot/pivot_controller.js index 12314a2e9aa..ed194cab709 100644 --- a/addons/web/static/src/views/pivot/pivot_controller.js +++ b/addons/web/static/src/views/pivot/pivot_controller.js @@ -1,9 +1,5 @@ /** @odoo-module **/ -import { Dropdown } from "@web/core/dropdown/dropdown"; -import { DropdownItem } from "@web/core/dropdown/dropdown_item"; -import { download } from "@web/core/network/download"; -import { useService } from "@web/core/utils/hooks"; import { Layout } from "@web/search/layout"; import { useModel } from "@web/views/model"; import { standardViewProps } from "@web/views/standard_view_props"; @@ -14,7 +10,6 @@ import { Component, useRef } from "@odoo/owl"; export class PivotController extends Component { setup() { - this.actionService = useService("action"); this.model = useModel(this.props.Model, this.props.modelParams); useSetupView({ @@ -36,108 +31,14 @@ export class PivotController extends Component { pivot_row_groupby: this.model.metaData.fullRowGroupBys, }; } - - //-------------------------------------------------------------------------- - // Handlers - //-------------------------------------------------------------------------- - - /** - * Exports the current pivot table data in a xls file. For this, we have to - * serialize the current state, then call the server /web/pivot/export_xlsx. - * Force a reload before exporting to ensure to export up-to-date data. - */ - onDownloadButtonClicked() { - if (this.model.getTableWidth() > 16384) { - throw new Error( - this.env._t( - "For Excel compatibility, data cannot be exported if there are more than 16384 columns.\n\nTip: try to flip axis, filter further or reduce the number of measures." - ) - ); - } - const table = this.model.exportData(); - download({ - url: "/web/pivot/export_xlsx", - data: { data: JSON.stringify(table) }, - }); - } - /** - * Expands all groups - */ - onExpandButtonClicked() { - this.model.expandAll(); - } - /** - * Flips axis - */ - onFlipButtonClicked() { - this.model.flip(); - } - /** - * Toggles the given measure - * - * @param {Object} param0 - * @param {string} param0.measure - */ - onMeasureSelected({ measure }) { - this.model.toggleMeasure(measure); - } - /** - * Execute the action to open the view on the current model. - * - * @param {Array} domain - * @param {Array} views - * @param {Object} context - */ - openView(domain, views, context) { - this.actionService.doAction({ - type: "ir.actions.act_window", - name: this.model.metaData.title, - res_model: this.props.resModel, - views: views, - view_mode: "list", - target: "current", - context, - domain, - }); - } - /** - * @param {CustomEvent} ev - */ - onOpenView(cell) { - if (cell.value === undefined || this.model.metaData.disableLinking) { - return; - } - - const context = Object.assign({}, this.model.searchParams.context); - Object.keys(context).forEach((x) => { - if (x === "group_by" || x.startsWith("search_default_")) { - delete context[x]; - } - }); - - // retrieve form and list view ids from the action - const { views = [] } = this.env.config; - this.views = ["list", "form"].map((viewType) => { - const view = views.find((view) => view[1] === viewType); - return [view ? view[0] : false, viewType]; - }); - - const group = { - rowValues: cell.groupId[0], - colValues: cell.groupId[1], - originIndex: cell.originIndexes[0], - }; - this.openView(this.model.getGroupDomain(group), this.views, context); - } } PivotController.template = "web.PivotView"; -PivotController.components = { Dropdown, DropdownItem, Layout, SearchBar }; +PivotController.components = { Layout, SearchBar }; PivotController.props = { ...standardViewProps, Model: Function, modelParams: Object, Renderer: Function, - buttonTemplate: String, }; diff --git a/addons/web/static/src/views/pivot/pivot_controller.xml b/addons/web/static/src/views/pivot/pivot_controller.xml index cab963ac771..513bca8227d 100644 --- a/addons/web/static/src/views/pivot/pivot_controller.xml +++ b/addons/web/static/src/views/pivot/pivot_controller.xml @@ -2,26 +2,25 @@ - -
- - - @@ -38,7 +37,7 @@ - +
diff --git a/addons/web/static/src/views/pivot/pivot_renderer.js b/addons/web/static/src/views/pivot/pivot_renderer.js index 3ebb8ac5665..f472aa2352c 100644 --- a/addons/web/static/src/views/pivot/pivot_renderer.js +++ b/addons/web/static/src/views/pivot/pivot_renderer.js @@ -3,15 +3,20 @@ import { CheckBox } from "@web/core/checkbox/checkbox"; import { localization } from "@web/core/l10n/localization"; import { registry } from "@web/core/registry"; +import { Dropdown } from "@web/core/dropdown/dropdown"; +import { DropdownItem } from "@web/core/dropdown/dropdown_item"; import { formatPercentage } from "@web/views/fields/formatters"; import { PivotGroupByMenu } from "@web/views/pivot/pivot_group_by_menu"; import fieldUtils from "web.field_utils"; import { Component, onWillUpdateProps, useRef } from "@odoo/owl"; +import { download } from "@web/core/network/download"; +import { useService } from "@web/core/utils/hooks"; const formatters = registry.category("formatters"); export class PivotRenderer extends Component { setup() { + this.actionService = useService("action"); this.model = this.props.model; this.table = this.model.getTable(); this.l10n = localization; @@ -71,9 +76,6 @@ export class PivotRenderer extends Component { // Handlers //---------------------------------------------------------------------- - onCellClicked(cell) { - this.props.onCellClicked(cell); - } /** * Handle the adding of a custom groupby (inside the view, not the searchview). * @@ -148,7 +150,100 @@ export class PivotRenderer extends Component { .querySelectorAll(".o_cell_hover") .forEach((elt) => elt.classList.remove("o_cell_hover")); } + + //-------------------------------------------------------------------------- + // Handlers + //-------------------------------------------------------------------------- + + /** + * Exports the current pivot table data in a xls file. For this, we have to + * serialize the current state, then call the server /web/pivot/export_xlsx. + * Force a reload before exporting to ensure to export up-to-date data. + */ + onDownloadButtonClicked() { + if (this.model.getTableWidth() > 16384) { + throw new Error( + this.env._t( + "For Excel compatibility, data cannot be exported if there are more than 16384 columns.\n\nTip: try to flip axis, filter further or reduce the number of measures." + ) + ); + } + const table = this.model.exportData(); + download({ + url: "/web/pivot/export_xlsx", + data: { data: JSON.stringify(table) }, + }); + } + /** + * Expands all groups + */ + onExpandButtonClicked() { + this.model.expandAll(); + } + /** + * Flips axis + */ + onFlipButtonClicked() { + this.model.flip(); + } + /** + * Toggles the given measure + * + * @param {Object} param0 + * @param {string} param0.measure + */ + onMeasureSelected({ measure }) { + this.model.toggleMeasure(measure); + } + /** + * Execute the action to open the view on the current model. + * + * @param {Array} domain + * @param {Array} views + * @param {Object} context + */ + openView(domain, views, context) { + this.actionService.doAction({ + type: "ir.actions.act_window", + name: this.model.metaData.title, + res_model: this.model.metaData.resModel, + views: views, + view_mode: "list", + target: "current", + context, + domain, + }); + } + /** + * @param {CustomEvent} ev + */ + onOpenView(cell) { + if (cell.value === undefined || this.model.metaData.disableLinking) { + return; + } + + const context = Object.assign({}, this.model.searchParams.context); + Object.keys(context).forEach((x) => { + if (x === "group_by" || x.startsWith("search_default_")) { + delete context[x]; + } + }); + + // retrieve form and list view ids from the action + const { views = [] } = this.env.config; + this.views = ["list", "form"].map((viewType) => { + const view = views.find((view) => view[1] === viewType); + return [view ? view[0] : false, viewType]; + }); + + const group = { + rowValues: cell.groupId[0], + colValues: cell.groupId[1], + originIndex: cell.originIndexes[0], + }; + this.openView(this.model.getGroupDomain(group), this.views, context); + } } PivotRenderer.template = "web.PivotRenderer"; -PivotRenderer.components = { CheckBox, PivotGroupByMenu }; -PivotRenderer.props = ["model", "onCellClicked"]; +PivotRenderer.components = { Dropdown, DropdownItem, CheckBox, PivotGroupByMenu }; +PivotRenderer.props = ["model"]; diff --git a/addons/web/static/src/views/pivot/pivot_renderer.xml b/addons/web/static/src/views/pivot/pivot_renderer.xml index 8f9b0a4095b..971e48864e0 100644 --- a/addons/web/static/src/views/pivot/pivot_renderer.xml +++ b/addons/web/static/src/views/pivot/pivot_renderer.xml @@ -2,6 +2,7 @@ +
{ const modelParams = {}; @@ -57,7 +56,6 @@ export const pivotView = { Model: view.Model, modelParams, Renderer: view.Renderer, - buttonTemplate: view.buttonTemplate, }; }, }; diff --git a/addons/web/static/src/webclient/settings_form_view/settings_form_view.xml b/addons/web/static/src/webclient/settings_form_view/settings_form_view.xml index debdc49c28e..a9791831949 100644 --- a/addons/web/static/src/webclient/settings_form_view/settings_form_view.xml +++ b/addons/web/static/src/webclient/settings_form_view/settings_form_view.xml @@ -28,7 +28,7 @@ - +