[MIG] web_pivot_computed_measure: Migration to 16.0

This commit is contained in:
Carlos Roca
2024-02-27 13:18:31 +01:00
parent f45795b24c
commit deae402f2a
12 changed files with 84 additions and 78 deletions

View File

@@ -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);

View File

@@ -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,
};

View File

@@ -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", {

View File

@@ -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) {

View File

@@ -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;
},
});

View File

@@ -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"]',

View File

@@ -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"