[MIG] web_pivot_computed_measure: Migration to 16.0

pull/2755/head
Carlos Roca 2024-02-27 13:18:31 +01:00
parent 1ea97cc177
commit 8bf89cfd84
12 changed files with 65 additions and 51 deletions

View File

@ -0,0 +1 @@
odoo-test-helper

View File

@ -7,7 +7,7 @@ Web Pivot Computed Measure
!! This file is generated by oca-gen-addon-readme !! !! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !! !! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:34691d378ce32fade67311831059070fab3df66f5cb2ec7fa88287018b85de7b !! source digest: sha256:4cef60dd775467b756ccbacb8c215bba0bc74fd32e1917c8b15c3be9de6302a1
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png .. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
@ -17,13 +17,13 @@ Web Pivot Computed Measure
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
:alt: License: AGPL-3 :alt: License: AGPL-3
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fweb-lightgray.png?logo=github .. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fweb-lightgray.png?logo=github
:target: https://github.com/OCA/web/tree/15.0/web_pivot_computed_measure :target: https://github.com/OCA/web/tree/16.0/web_pivot_computed_measure
:alt: OCA/web :alt: OCA/web
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png .. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/web-15-0/web-15-0-web_pivot_computed_measure :target: https://translation.odoo-community.org/projects/web-16-0/web-16-0-web_pivot_computed_measure
:alt: Translate me on Weblate :alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png .. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png
:target: https://runboat.odoo-community.org/builds?repo=OCA/web&target_branch=15.0 :target: https://runboat.odoo-community.org/builds?repo=OCA/web&target_branch=16.0
:alt: Try me on Runboat :alt: Try me on Runboat
|badge1| |badge2| |badge3| |badge4| |badge5| |badge1| |badge2| |badge3| |badge4| |badge5|
@ -68,7 +68,7 @@ Known issues / Roadmap
====================== ======================
#. Add support to define a style for a computed measure (ex. colored) #. Add support to define a style for a computed measure (ex. colored)
#. Use t-model to data-binding instad of jquery selectors #. Use t-model to data-binding instead of jquery selectors
Bug Tracker Bug Tracker
=========== ===========
@ -76,7 +76,7 @@ Bug Tracker
Bugs are tracked on `GitHub Issues <https://github.com/OCA/web/issues>`_. Bugs are tracked on `GitHub Issues <https://github.com/OCA/web/issues>`_.
In case of trouble, please check there if your issue has already been reported. In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us to smash it by providing a detailed and welcomed If you spotted it first, help us to smash it by providing a detailed and welcomed
`feedback <https://github.com/OCA/web/issues/new?body=module:%20web_pivot_computed_measure%0Aversion:%2015.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_. `feedback <https://github.com/OCA/web/issues/new?body=module:%20web_pivot_computed_measure%0Aversion:%2016.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
Do not contact contributors directly about support or help with technical issues. Do not contact contributors directly about support or help with technical issues.
@ -111,6 +111,14 @@ OCA, or the Odoo Community Association, is a nonprofit organization whose
mission is to support the collaborative development of Odoo features and mission is to support the collaborative development of Odoo features and
promote its widespread use. promote its widespread use.
This module is part of the `OCA/web <https://github.com/OCA/web/tree/15.0/web_pivot_computed_measure>`_ project on GitHub. .. |maintainer-CarlosRoca13| image:: https://github.com/CarlosRoca13.png?size=40px
:target: https://github.com/CarlosRoca13
:alt: CarlosRoca13
Current `maintainer <https://odoo-community.org/page/maintainer-role>`__:
|maintainer-CarlosRoca13|
This module is part of the `OCA/web <https://github.com/OCA/web/tree/16.0/web_pivot_computed_measure>`_ project on GitHub.
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

View File

@ -3,21 +3,20 @@
{ {
"name": "Web Pivot Computed Measure", "name": "Web Pivot Computed Measure",
"category": "web", "category": "web",
"version": "15.0.1.0.3", "version": "16.0.1.0.0",
"author": "Tecnativa, Odoo Community Association (OCA)", "author": "Tecnativa, Odoo Community Association (OCA)",
"license": "AGPL-3", "license": "AGPL-3",
"website": "https://github.com/OCA/web", "website": "https://github.com/OCA/web",
"depends": ["web"], "depends": ["web"],
"auto_install": False, "auto_install": False,
"installable": True, "installable": True,
"maintainers": ["CarlosRoca13"],
"assets": { "assets": {
"web.assets_qweb": [
"/web_pivot_computed_measure/static/src/**/*.xml",
],
"web.assets_backend": [ "web.assets_backend": [
"/web_pivot_computed_measure/static/src/**/*.esm.js", "/web_pivot_computed_measure/static/src/**/*.esm.js",
"/web_pivot_computed_measure/static/src/**/*.scss", "/web_pivot_computed_measure/static/src/**/*.scss",
("remove", "/web_pivot_computed_measure/static/src/test/*.esm.js"), ("remove", "/web_pivot_computed_measure/static/src/test/*.esm.js"),
"/web_pivot_computed_measure/static/src/**/*.xml",
], ],
"web.assets_tests": [ "web.assets_tests": [
"/web_pivot_computed_measure/static/src/test/test.esm.js", "/web_pivot_computed_measure/static/src/test/test.esm.js",

View File

@ -1,2 +1,2 @@
#. Add support to define a style for a computed measure (ex. colored) #. Add support to define a style for a computed measure (ex. colored)
#. Use t-model to data-binding instad of jquery selectors #. Use t-model to data-binding instead of jquery selectors

View File

@ -367,9 +367,9 @@ ul.auto-toc {
!! This file is generated by oca-gen-addon-readme !! !! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !! !! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:34691d378ce32fade67311831059070fab3df66f5cb2ec7fa88287018b85de7b !! source digest: sha256:4cef60dd775467b756ccbacb8c215bba0bc74fd32e1917c8b15c3be9de6302a1
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! --> !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
<p><a class="reference external image-reference" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external image-reference" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/licence-AGPL--3-blue.png" /></a> <a class="reference external image-reference" href="https://github.com/OCA/web/tree/15.0/web_pivot_computed_measure"><img alt="OCA/web" src="https://img.shields.io/badge/github-OCA%2Fweb-lightgray.png?logo=github" /></a> <a class="reference external image-reference" href="https://translation.odoo-community.org/projects/web-15-0/web-15-0-web_pivot_computed_measure"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external image-reference" href="https://runboat.odoo-community.org/builds?repo=OCA/web&amp;target_branch=15.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p> <p><a class="reference external image-reference" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external image-reference" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/licence-AGPL--3-blue.png" /></a> <a class="reference external image-reference" href="https://github.com/OCA/web/tree/16.0/web_pivot_computed_measure"><img alt="OCA/web" src="https://img.shields.io/badge/github-OCA%2Fweb-lightgray.png?logo=github" /></a> <a class="reference external image-reference" href="https://translation.odoo-community.org/projects/web-16-0/web-16-0-web_pivot_computed_measure"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external image-reference" href="https://runboat.odoo-community.org/builds?repo=OCA/web&amp;target_branch=16.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
<p>Adds support for computed measures on the pivot view.</p> <p>Adds support for computed measures on the pivot view.</p>
<p><strong>Table of contents</strong></p> <p><strong>Table of contents</strong></p>
<div class="contents local topic" id="contents"> <div class="contents local topic" id="contents">
@ -434,7 +434,7 @@ cant be deactivated until you have deactivate the computed measure.</p>
<h1><a class="toc-backref" href="#toc-entry-2">Known issues / Roadmap</a></h1> <h1><a class="toc-backref" href="#toc-entry-2">Known issues / Roadmap</a></h1>
<ol class="arabic simple"> <ol class="arabic simple">
<li>Add support to define a style for a computed measure (ex. colored)</li> <li>Add support to define a style for a computed measure (ex. colored)</li>
<li>Use t-model to data-binding instad of jquery selectors</li> <li>Use t-model to data-binding instead of jquery selectors</li>
</ol> </ol>
</div> </div>
<div class="section" id="bug-tracker"> <div class="section" id="bug-tracker">
@ -442,7 +442,7 @@ cant be deactivated until you have deactivate the computed measure.</p>
<p>Bugs are tracked on <a class="reference external" href="https://github.com/OCA/web/issues">GitHub Issues</a>. <p>Bugs are tracked on <a class="reference external" href="https://github.com/OCA/web/issues">GitHub Issues</a>.
In case of trouble, please check there if your issue has already been reported. In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us to smash it by providing a detailed and welcomed If you spotted it first, help us to smash it by providing a detailed and welcomed
<a class="reference external" href="https://github.com/OCA/web/issues/new?body=module:%20web_pivot_computed_measure%0Aversion:%2015.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p> <a class="reference external" href="https://github.com/OCA/web/issues/new?body=module:%20web_pivot_computed_measure%0Aversion:%2016.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
<p>Do not contact contributors directly about support or help with technical issues.</p> <p>Do not contact contributors directly about support or help with technical issues.</p>
</div> </div>
<div class="section" id="credits"> <div class="section" id="credits">
@ -472,7 +472,9 @@ If you spotted it first, help us to smash it by providing a detailed and welcome
<p>OCA, or the Odoo Community Association, is a nonprofit organization whose <p>OCA, or the Odoo Community Association, is a nonprofit organization whose
mission is to support the collaborative development of Odoo features and mission is to support the collaborative development of Odoo features and
promote its widespread use.</p> promote its widespread use.</p>
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/web/tree/15.0/web_pivot_computed_measure">OCA/web</a> project on GitHub.</p> <p>Current <a class="reference external" href="https://odoo-community.org/page/maintainer-role">maintainer</a>:</p>
<p><a class="reference external image-reference" href="https://github.com/CarlosRoca13"><img alt="CarlosRoca13" src="https://github.com/CarlosRoca13.png?size=40px" /></a></p>
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/web/tree/16.0/web_pivot_computed_measure">OCA/web</a> project on GitHub.</p>
<p>You are welcome to contribute. To learn how please visit <a class="reference external" href="https://odoo-community.org/page/Contribute">https://odoo-community.org/page/Contribute</a>.</p> <p>You are welcome to contribute. To learn how please visit <a class="reference external" href="https://odoo-community.org/page/Contribute">https://odoo-community.org/page/Contribute</a>.</p>
</div> </div>
</div> </div>

View File

@ -2,8 +2,7 @@
/* Copyright 2022 Tecnativa - Carlos Roca /* Copyright 2022 Tecnativa - Carlos Roca
* License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html) */ * License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html) */
const {Component, QWeb} = owl; import {Component, useState} from "@odoo/owl";
const {useState} = owl.hooks;
/** /**
* @extends Component * @extends Component
@ -48,4 +47,3 @@ DropdownItemCustomMeasure.props = {
// uses Measures like the graph view. // uses Measures like the graph view.
model: Object, 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) */ * License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html) */
import {PivotModel} from "@web/views/pivot/pivot_model"; import {PivotModel} from "@web/views/pivot/pivot_model";
import {patch} from "web.utils"; import {patch} from "@web/core/utils/patch";
import {computeReportMeasures} from "@web/views/helpers/utils"; import {computeReportMeasures} from "@web/views/utils";
import {evalOperation} from "../helpers/utils.esm"; import {evalOperation} from "../helpers/utils.esm";
patch(PivotModel.prototype, "web_pivot_computed_measure.PivotModel", { 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) */ * License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html) */
import {PivotRenderer} from "@web/views/pivot/pivot_renderer"; 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", { patch(PivotRenderer.prototype, "web_pivot_computed_measure.PivotRenderer", {
getFormattedValue(cell) { 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, 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"]', 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" /> <div role="separator" class="dropdown-divider" t-if="add_computed_measures" />
<t t-foreach="measures" t-as="measure" t-key="measure_value.name"> <t t-foreach="measures" t-as="measure" t-key="measure_value.name">
<DropdownItem <DropdownItem
class="{ o_menu_item: true, selected: activeMeasures.includes(measure) }"
t-if="add_computed_measures and measure.startsWith('__computed_')" t-if="add_computed_measures and measure.startsWith('__computed_')"
class="o_menu_item dropdown-item" t-esc="measures[measure].string"
t-att-class="{ selected: activeMeasures.includes(measure) }"
payload="{ measure: measure_value.name }"
parentClosingMode="'none'" parentClosingMode="'none'"
> onSelected="() => this.onMeasureSelected({ measure: measure_value.name })"
<t t-esc="measures[measure].string" /> />
</DropdownItem>
</t> </t>
<DropdownItemCustomMeasure <DropdownItemCustomMeasure
measures="measures" measures="measures"