mirror of
https://github.com/OCA/web.git
synced 2025-02-22 13:21:25 +02:00
[MIG] web_pivot_computed_measure: Migration to 16.0
This commit is contained in:
@@ -2,8 +2,7 @@
|
||||
/* Copyright 2022 Tecnativa - Carlos Roca
|
||||
* License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html) */
|
||||
|
||||
const {Component, QWeb} = owl;
|
||||
const {useState} = owl.hooks;
|
||||
import {Component, useState} from "@odoo/owl";
|
||||
|
||||
/**
|
||||
* @extends Component
|
||||
@@ -48,4 +47,3 @@ DropdownItemCustomMeasure.props = {
|
||||
// uses Measures like the graph view.
|
||||
model: Object,
|
||||
};
|
||||
QWeb.registerComponent("DropdownItemCustomMeasure", DropdownItemCustomMeasure);
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
/** @odoo-module **/
|
||||
/* Copyright 2024 Tecnativa - Carlos Roca
|
||||
* License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html) */
|
||||
|
||||
import {PivotController} from "@web/views/pivot/pivot_controller";
|
||||
import {patch} from "@web/core/utils/patch";
|
||||
import {DropdownItemCustomMeasure} from "../dropdown_item_custom_measure/dropdown_item_custom_measure.esm";
|
||||
|
||||
patch(PivotController.prototype, "web_pivot_computed_measure.PivotController", {
|
||||
/**
|
||||
* Add computed_measures to context key to avoid loosing info when saving the
|
||||
* filter to favorites.
|
||||
*
|
||||
* @override
|
||||
*/
|
||||
getContext() {
|
||||
var res = this._super(...arguments);
|
||||
res.pivot_computed_measures = this.model._computed_measures;
|
||||
return res;
|
||||
},
|
||||
});
|
||||
|
||||
PivotController.components = {
|
||||
...PivotController.components,
|
||||
DropdownItemCustomMeasure,
|
||||
};
|
||||
@@ -4,8 +4,8 @@
|
||||
* License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html) */
|
||||
|
||||
import {PivotModel} from "@web/views/pivot/pivot_model";
|
||||
import {patch} from "web.utils";
|
||||
import {computeReportMeasures} from "@web/views/helpers/utils";
|
||||
import {patch} from "@web/core/utils/patch";
|
||||
import {computeReportMeasures} from "@web/views/utils";
|
||||
import {evalOperation} from "../helpers/utils.esm";
|
||||
|
||||
patch(PivotModel.prototype, "web_pivot_computed_measure.PivotModel", {
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
* License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html) */
|
||||
|
||||
import {PivotRenderer} from "@web/views/pivot/pivot_renderer";
|
||||
import {patch} from "web.utils";
|
||||
import {patch} from "@web/core/utils/patch";
|
||||
|
||||
patch(PivotRenderer.prototype, "web_pivot_computed_measure.PivotRenderer", {
|
||||
getFormattedValue(cell) {
|
||||
|
||||
@@ -1,20 +0,0 @@
|
||||
/** @odoo-module **/
|
||||
/* Copyright 2022 Tecnativa - Carlos Roca
|
||||
* License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html) */
|
||||
|
||||
import {PivotView} from "@web/views/pivot/pivot_view";
|
||||
import {patch} from "web.utils";
|
||||
|
||||
patch(PivotView.prototype, "web_pivot_computed_measure.PivotView", {
|
||||
/**
|
||||
* Add computed_measures to context key to avoid loosing info when saving the
|
||||
* filter to favorites.
|
||||
*
|
||||
* @override
|
||||
*/
|
||||
getContext() {
|
||||
var res = this._super(...arguments);
|
||||
res.pivot_computed_measures = this.model._computed_measures;
|
||||
return res;
|
||||
},
|
||||
});
|
||||
@@ -11,9 +11,11 @@ tour.register(
|
||||
test: true,
|
||||
},
|
||||
[
|
||||
tour.stepUtils.showAppsMenuItem(),
|
||||
{
|
||||
trigger: 'a[data-menu-xmlid="base.menu_administration"]',
|
||||
trigger: ".o_navbar_apps_menu button",
|
||||
},
|
||||
{
|
||||
trigger: '.o_app[data-menu-xmlid="base.menu_administration"]',
|
||||
},
|
||||
{
|
||||
trigger: 'button[data-menu-xmlid="base.menu_users"]',
|
||||
|
||||
@@ -8,14 +8,12 @@
|
||||
<div role="separator" class="dropdown-divider" t-if="add_computed_measures" />
|
||||
<t t-foreach="measures" t-as="measure" t-key="measure_value.name">
|
||||
<DropdownItem
|
||||
class="{ o_menu_item: true, selected: activeMeasures.includes(measure) }"
|
||||
t-if="add_computed_measures and measure.startsWith('__computed_')"
|
||||
class="o_menu_item dropdown-item"
|
||||
t-att-class="{ selected: activeMeasures.includes(measure) }"
|
||||
payload="{ measure: measure_value.name }"
|
||||
t-esc="measures[measure].string"
|
||||
parentClosingMode="'none'"
|
||||
>
|
||||
<t t-esc="measures[measure].string" />
|
||||
</DropdownItem>
|
||||
onSelected="() => this.onMeasureSelected({ measure: measure_value.name })"
|
||||
/>
|
||||
</t>
|
||||
<DropdownItemCustomMeasure
|
||||
measures="measures"
|
||||
|
||||
Reference in New Issue
Block a user