diff --git a/setup/web_pivot_computed_measure/odoo/addons/web_pivot_computed_measure b/setup/web_pivot_computed_measure/odoo/addons/web_pivot_computed_measure new file mode 120000 index 000000000..282ada6fd --- /dev/null +++ b/setup/web_pivot_computed_measure/odoo/addons/web_pivot_computed_measure @@ -0,0 +1 @@ +../../../../web_pivot_computed_measure \ No newline at end of file diff --git a/setup/web_pivot_computed_measure/setup.py b/setup/web_pivot_computed_measure/setup.py new file mode 100644 index 000000000..28c57bb64 --- /dev/null +++ b/setup/web_pivot_computed_measure/setup.py @@ -0,0 +1,6 @@ +import setuptools + +setuptools.setup( + setup_requires=['setuptools-odoo'], + odoo_addon=True, +) diff --git a/test-requirements.txt b/test-requirements.txt new file mode 100644 index 000000000..4ad8e0ece --- /dev/null +++ b/test-requirements.txt @@ -0,0 +1 @@ +odoo-test-helper diff --git a/web_pivot_computed_measure/README.rst b/web_pivot_computed_measure/README.rst new file mode 100644 index 000000000..1b03b9796 --- /dev/null +++ b/web_pivot_computed_measure/README.rst @@ -0,0 +1,124 @@ +========================== +Web Pivot Computed Measure +========================== + +.. + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! source digest: sha256:4cef60dd775467b756ccbacb8c215bba0bc74fd32e1917c8b15c3be9de6302a1 + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png + :target: https://odoo-community.org/page/development-status + :alt: Beta +.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png + :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html + :alt: License: AGPL-3 +.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fweb-lightgray.png?logo=github + :target: https://github.com/OCA/web/tree/16.0/web_pivot_computed_measure + :alt: OCA/web +.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png + :target: https://translation.odoo-community.org/projects/web-16-0/web-16-0-web_pivot_computed_measure + :alt: Translate me on Weblate +.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png + :target: https://runboat.odoo-community.org/builds?repo=OCA/web&target_branch=16.0 + :alt: Try me on Runboat + +|badge1| |badge2| |badge3| |badge4| |badge5| + +Adds support for computed measures on the pivot view. + +**Table of contents** + +.. contents:: + :local: + +Usage +===== + +Go to pivot view and click on the "Measures" menu, you will see +a new option called 'Computed Measure'. + +You have the follow options to create a 'computed measure': + - Measure 1: Used in 'operation formula' as 'm1' + - Measure 2: Used in 'operation formula' as 'm2' + - Operation: The formula + - Sum: m1 + m2 + - Sub: m1 - m2 + - Mult: m1 * m2 + - Div: m1 / m2 (Format: Float) + - Perc m1 / m2 (Format: Percentage) + - Custom: Special option only visible in debug mode to write a custom formula. + - Name: The name of the new measure (emtpy = auto-generated) + - Format: How will the value be printed + - Integer + - Float + - Percentage (value * 100) + - Formula*: Custom operation formula + These formula is evaluated using 'PY.eval' + +These computed measures can be mixed (You can reuse it to make new computed measures) and saved as favorites. + +Notice that "measures/computed measures" involved in an active 'computed measure' +can't be deactivated until you have deactivate the 'computed measure'. + +Known issues / Roadmap +====================== + +#. Add support to define a style for a computed measure (ex. colored) +#. Use t-model to data-binding instead of jquery selectors + +Bug Tracker +=========== + +Bugs are tracked on `GitHub Issues `_. +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 +`feedback `_. + +Do not contact contributors directly about support or help with technical issues. + +Credits +======= + +Authors +~~~~~~~ + +* Tecnativa + +Contributors +~~~~~~~~~~~~ + +* `Tecnativa `_: + + * Alexandre D. Díaz + * Pedro M. Baeza + * Ernesto Tejeda + * Carlos Roca + +Maintainers +~~~~~~~~~~~ + +This module is maintained by the OCA. + +.. image:: https://odoo-community.org/logo.png + :alt: Odoo Community Association + :target: https://odoo-community.org + +OCA, or the Odoo Community Association, is a nonprofit organization whose +mission is to support the collaborative development of Odoo features and +promote its widespread use. + +.. |maintainer-CarlosRoca13| image:: https://github.com/CarlosRoca13.png?size=40px + :target: https://github.com/CarlosRoca13 + :alt: CarlosRoca13 + +Current `maintainer `__: + +|maintainer-CarlosRoca13| + +This module is part of the `OCA/web `_ project on GitHub. + +You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/web_pivot_computed_measure/__init__.py b/web_pivot_computed_measure/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/web_pivot_computed_measure/__manifest__.py b/web_pivot_computed_measure/__manifest__.py new file mode 100644 index 000000000..02260c9c7 --- /dev/null +++ b/web_pivot_computed_measure/__manifest__.py @@ -0,0 +1,25 @@ +# Copyright 2020 Tecnativa - Alexandre Díaz +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html) +{ + "name": "Web Pivot Computed Measure", + "category": "web", + "version": "16.0.1.0.0", + "author": "Tecnativa, Odoo Community Association (OCA)", + "license": "AGPL-3", + "website": "https://github.com/OCA/web", + "depends": ["web"], + "auto_install": False, + "installable": True, + "maintainers": ["CarlosRoca13"], + "assets": { + "web.assets_backend": [ + "/web_pivot_computed_measure/static/src/**/*.esm.js", + "/web_pivot_computed_measure/static/src/**/*.scss", + ("remove", "/web_pivot_computed_measure/static/src/test/*.esm.js"), + "/web_pivot_computed_measure/static/src/**/*.xml", + ], + "web.assets_tests": [ + "/web_pivot_computed_measure/static/src/test/test.esm.js", + ], + }, +} diff --git a/web_pivot_computed_measure/i18n/ca.po b/web_pivot_computed_measure/i18n/ca.po new file mode 100644 index 000000000..2286bb66e --- /dev/null +++ b/web_pivot_computed_measure/i18n/ca.po @@ -0,0 +1,161 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * web_pivot_computed_measure +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 13.0\n" +"Report-Msgid-Bugs-To: \n" +"PO-Revision-Date: 2021-07-05 12:48+0000\n" +"Last-Translator: jabelchi \n" +"Language-Team: none\n" +"Language: ca\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: nplurals=2; plural=n != 1;\n" +"X-Generator: Weblate 4.3.2\n" + +#. module: web_pivot_computed_measure +#. openerp-web +#: code:addons/web_pivot_computed_measure/static/src/view.xml:0 +#, python-format +msgid "!measure.startsWith('__computed_')" +msgstr "" + +#. module: web_pivot_computed_measure +#. openerp-web +#: code:addons/web_pivot_computed_measure/static/src/dropdown_item_custom_measure/dropdown_item_custom_measure.xml:0 +#, python-format +msgid "Add" +msgstr "Afegir" + +#. module: web_pivot_computed_measure +#. openerp-web +#: code:addons/web_pivot_computed_measure/static/src/dropdown_item_custom_measure/dropdown_item_custom_measure.xml:0 +#, python-format +msgid "Can be empty" +msgstr "Pot estar buit" + +#. module: web_pivot_computed_measure +#. openerp-web +#: code:addons/web_pivot_computed_measure/static/src/dropdown_item_custom_measure/dropdown_item_custom_measure.xml:0 +#, python-format +msgid "Computed Measure" +msgstr "Mesura calculada" + +#. module: web_pivot_computed_measure +#. openerp-web +#: code:addons/web_pivot_computed_measure/static/src/dropdown_item_custom_measure/dropdown_item_custom_measure.xml:0 +#, python-format +msgid "Custom" +msgstr "Personalitat" + +#. module: web_pivot_computed_measure +#. openerp-web +#: code:addons/web_pivot_computed_measure/static/src/dropdown_item_custom_measure/dropdown_item_custom_measure.xml:0 +#, python-format +msgid "Div (m1 / m2)" +msgstr "Div (m1 / m2)" + +#. module: web_pivot_computed_measure +#. openerp-web +#: code:addons/web_pivot_computed_measure/static/src/dropdown_item_custom_measure/dropdown_item_custom_measure.xml:0 +#, python-format +msgid "Float" +msgstr "Comma flotant" + +#. module: web_pivot_computed_measure +#. openerp-web +#: code:addons/web_pivot_computed_measure/static/src/dropdown_item_custom_measure/dropdown_item_custom_measure.xml:0 +#, python-format +msgid "Format" +msgstr "Format" + +#. module: web_pivot_computed_measure +#. openerp-web +#: code:addons/web_pivot_computed_measure/static/src/dropdown_item_custom_measure/dropdown_item_custom_measure.xml:0 +#, python-format +msgid "Formula" +msgstr "Fórmula" + +#. module: web_pivot_computed_measure +#. openerp-web +#: code:addons/web_pivot_computed_measure/static/src/dropdown_item_custom_measure/dropdown_item_custom_measure.xml:0 +#, python-format +msgid "Integer" +msgstr "Enter" + +#. module: web_pivot_computed_measure +#. openerp-web +#: code:addons/web_pivot_computed_measure/static/src/dropdown_item_custom_measure/dropdown_item_custom_measure.xml:0 +#, python-format +msgid "Measure 1" +msgstr "Mesura 1" + +#. module: web_pivot_computed_measure +#. openerp-web +#: code:addons/web_pivot_computed_measure/static/src/dropdown_item_custom_measure/dropdown_item_custom_measure.xml:0 +#, python-format +msgid "Measure 2" +msgstr "Mesura 2" + +#. module: web_pivot_computed_measure +#. openerp-web +#: code:addons/web_pivot_computed_measure/static/src/dropdown_item_custom_measure/dropdown_item_custom_measure.xml:0 +#, python-format +msgid "Mult (m1 * m2)" +msgstr "Mult (m1 * m2)" + +#. module: web_pivot_computed_measure +#. openerp-web +#: code:addons/web_pivot_computed_measure/static/src/dropdown_item_custom_measure/dropdown_item_custom_measure.xml:0 +#, python-format +msgid "Name" +msgstr "Nom" + +#. module: web_pivot_computed_measure +#. openerp-web +#: code:addons/web_pivot_computed_measure/static/src/dropdown_item_custom_measure/dropdown_item_custom_measure.xml:0 +#, python-format +msgid "Operation" +msgstr "Operació" + +#. module: web_pivot_computed_measure +#. openerp-web +#: code:addons/web_pivot_computed_measure/static/src/dropdown_item_custom_measure/dropdown_item_custom_measure.xml:0 +#, python-format +msgid "Perc (m1 * 100 / m2)" +msgstr "Perc (m1 * 100 / m2)" + +#. module: web_pivot_computed_measure +#. openerp-web +#: code:addons/web_pivot_computed_measure/static/src/dropdown_item_custom_measure/dropdown_item_custom_measure.xml:0 +#, python-format +msgid "Percentage" +msgstr "Percentatge" + +#. module: web_pivot_computed_measure +#. openerp-web +#: code:addons/web_pivot_computed_measure/static/src/dropdown_item_custom_measure/dropdown_item_custom_measure.xml:0 +#, python-format +msgid "Sub (m1 - m2)" +msgstr "Resta (m1 - m2)" + +#. module: web_pivot_computed_measure +#. openerp-web +#: code:addons/web_pivot_computed_measure/static/src/dropdown_item_custom_measure/dropdown_item_custom_measure.xml:0 +#, python-format +msgid "Sum (m1 + m2)" +msgstr "Suma (m1 + m2)" + +#. module: web_pivot_computed_measure +#. openerp-web +#: code:addons/web_pivot_computed_measure/static/src/pivot/pivot_model.esm.js:0 +#, python-format +msgid "" +"This measure is currently used by a 'computed measure'. Please, disable the " +"computed measure first." +msgstr "" +"Aquesta mesura s'usa actualment per una \"mesura calculada\". Si us plau, " +"inhabiliteu primer la mesura calculada." diff --git a/web_pivot_computed_measure/i18n/es.po b/web_pivot_computed_measure/i18n/es.po new file mode 100644 index 000000000..45d8d32bc --- /dev/null +++ b/web_pivot_computed_measure/i18n/es.po @@ -0,0 +1,162 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * web_pivot_computed_measure +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 12.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2022-11-22 12:42+0000\n" +"PO-Revision-Date: 2023-11-19 19:33+0000\n" +"Last-Translator: Ivorra78 \n" +"Language-Team: none\n" +"Language: es\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Plural-Forms: nplurals=2; plural=n != 1;\n" +"X-Generator: Weblate 4.17\n" + +#. module: web_pivot_computed_measure +#. openerp-web +#: code:addons/web_pivot_computed_measure/static/src/view.xml:0 +#, python-format +msgid "!measure.startsWith('__computed_')" +msgstr "!measure.startsWith('__computed_')" + +#. module: web_pivot_computed_measure +#. openerp-web +#: code:addons/web_pivot_computed_measure/static/src/dropdown_item_custom_measure/dropdown_item_custom_measure.xml:0 +#, python-format +msgid "Add" +msgstr "Añadir" + +#. module: web_pivot_computed_measure +#. openerp-web +#: code:addons/web_pivot_computed_measure/static/src/dropdown_item_custom_measure/dropdown_item_custom_measure.xml:0 +#, python-format +msgid "Can be empty" +msgstr "Puede estar vacío" + +#. module: web_pivot_computed_measure +#. openerp-web +#: code:addons/web_pivot_computed_measure/static/src/dropdown_item_custom_measure/dropdown_item_custom_measure.xml:0 +#, python-format +msgid "Computed Measure" +msgstr "Medida computada" + +#. module: web_pivot_computed_measure +#. openerp-web +#: code:addons/web_pivot_computed_measure/static/src/dropdown_item_custom_measure/dropdown_item_custom_measure.xml:0 +#, python-format +msgid "Custom" +msgstr "Customizado" + +#. module: web_pivot_computed_measure +#. openerp-web +#: code:addons/web_pivot_computed_measure/static/src/dropdown_item_custom_measure/dropdown_item_custom_measure.xml:0 +#, python-format +msgid "Div (m1 / m2)" +msgstr "Div (m1 / m2)" + +#. module: web_pivot_computed_measure +#. openerp-web +#: code:addons/web_pivot_computed_measure/static/src/dropdown_item_custom_measure/dropdown_item_custom_measure.xml:0 +#, python-format +msgid "Float" +msgstr "Flotador" + +#. module: web_pivot_computed_measure +#. openerp-web +#: code:addons/web_pivot_computed_measure/static/src/dropdown_item_custom_measure/dropdown_item_custom_measure.xml:0 +#, python-format +msgid "Format" +msgstr "Formato" + +#. module: web_pivot_computed_measure +#. openerp-web +#: code:addons/web_pivot_computed_measure/static/src/dropdown_item_custom_measure/dropdown_item_custom_measure.xml:0 +#, python-format +msgid "Formula" +msgstr "Fórmula" + +#. module: web_pivot_computed_measure +#. openerp-web +#: code:addons/web_pivot_computed_measure/static/src/dropdown_item_custom_measure/dropdown_item_custom_measure.xml:0 +#, python-format +msgid "Integer" +msgstr "Entero" + +#. module: web_pivot_computed_measure +#. openerp-web +#: code:addons/web_pivot_computed_measure/static/src/dropdown_item_custom_measure/dropdown_item_custom_measure.xml:0 +#, python-format +msgid "Measure 1" +msgstr "Medida 1" + +#. module: web_pivot_computed_measure +#. openerp-web +#: code:addons/web_pivot_computed_measure/static/src/dropdown_item_custom_measure/dropdown_item_custom_measure.xml:0 +#, python-format +msgid "Measure 2" +msgstr "Medida 2" + +#. module: web_pivot_computed_measure +#. openerp-web +#: code:addons/web_pivot_computed_measure/static/src/dropdown_item_custom_measure/dropdown_item_custom_measure.xml:0 +#, python-format +msgid "Mult (m1 * m2)" +msgstr "Mult (m1 * m2)" + +#. module: web_pivot_computed_measure +#. openerp-web +#: code:addons/web_pivot_computed_measure/static/src/dropdown_item_custom_measure/dropdown_item_custom_measure.xml:0 +#, python-format +msgid "Name" +msgstr "Nombre" + +#. module: web_pivot_computed_measure +#. openerp-web +#: code:addons/web_pivot_computed_measure/static/src/dropdown_item_custom_measure/dropdown_item_custom_measure.xml:0 +#, python-format +msgid "Operation" +msgstr "Operación" + +#. module: web_pivot_computed_measure +#. openerp-web +#: code:addons/web_pivot_computed_measure/static/src/dropdown_item_custom_measure/dropdown_item_custom_measure.xml:0 +#, python-format +msgid "Perc (m1 * 100 / m2)" +msgstr "Perc (m1 * 100 / m2)" + +#. module: web_pivot_computed_measure +#. openerp-web +#: code:addons/web_pivot_computed_measure/static/src/dropdown_item_custom_measure/dropdown_item_custom_measure.xml:0 +#, python-format +msgid "Percentage" +msgstr "Porcentaje" + +#. module: web_pivot_computed_measure +#. openerp-web +#: code:addons/web_pivot_computed_measure/static/src/dropdown_item_custom_measure/dropdown_item_custom_measure.xml:0 +#, python-format +msgid "Sub (m1 - m2)" +msgstr "Sub (m1 - m2)" + +#. module: web_pivot_computed_measure +#. openerp-web +#: code:addons/web_pivot_computed_measure/static/src/dropdown_item_custom_measure/dropdown_item_custom_measure.xml:0 +#, python-format +msgid "Sum (m1 + m2)" +msgstr "Sum (m1 + m2)" + +#. module: web_pivot_computed_measure +#. openerp-web +#: code:addons/web_pivot_computed_measure/static/src/pivot/pivot_model.esm.js:0 +#, python-format +msgid "" +"This measure is currently used by a 'computed measure'. Please, disable the " +"computed measure first." +msgstr "" +"Esta medida está utilizada por una 'medida computada'. Por favor, desabilita " +"la medida computada primero." diff --git a/web_pivot_computed_measure/i18n/web_pivot_computed_measure.pot b/web_pivot_computed_measure/i18n/web_pivot_computed_measure.pot new file mode 100644 index 000000000..117534c76 --- /dev/null +++ b/web_pivot_computed_measure/i18n/web_pivot_computed_measure.pot @@ -0,0 +1,156 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * web_pivot_computed_measure +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 15.0\n" +"Report-Msgid-Bugs-To: \n" +"Last-Translator: \n" +"Language-Team: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: \n" + +#. module: web_pivot_computed_measure +#. openerp-web +#: code:addons/web_pivot_computed_measure/static/src/view.xml:0 +#, python-format +msgid "!measure.startsWith('__computed_')" +msgstr "" + +#. module: web_pivot_computed_measure +#. openerp-web +#: code:addons/web_pivot_computed_measure/static/src/dropdown_item_custom_measure/dropdown_item_custom_measure.xml:0 +#, python-format +msgid "Add" +msgstr "" + +#. module: web_pivot_computed_measure +#. openerp-web +#: code:addons/web_pivot_computed_measure/static/src/dropdown_item_custom_measure/dropdown_item_custom_measure.xml:0 +#, python-format +msgid "Can be empty" +msgstr "" + +#. module: web_pivot_computed_measure +#. openerp-web +#: code:addons/web_pivot_computed_measure/static/src/dropdown_item_custom_measure/dropdown_item_custom_measure.xml:0 +#, python-format +msgid "Computed Measure" +msgstr "" + +#. module: web_pivot_computed_measure +#. openerp-web +#: code:addons/web_pivot_computed_measure/static/src/dropdown_item_custom_measure/dropdown_item_custom_measure.xml:0 +#, python-format +msgid "Custom" +msgstr "" + +#. module: web_pivot_computed_measure +#. openerp-web +#: code:addons/web_pivot_computed_measure/static/src/dropdown_item_custom_measure/dropdown_item_custom_measure.xml:0 +#, python-format +msgid "Div (m1 / m2)" +msgstr "" + +#. module: web_pivot_computed_measure +#. openerp-web +#: code:addons/web_pivot_computed_measure/static/src/dropdown_item_custom_measure/dropdown_item_custom_measure.xml:0 +#, python-format +msgid "Float" +msgstr "" + +#. module: web_pivot_computed_measure +#. openerp-web +#: code:addons/web_pivot_computed_measure/static/src/dropdown_item_custom_measure/dropdown_item_custom_measure.xml:0 +#, python-format +msgid "Format" +msgstr "" + +#. module: web_pivot_computed_measure +#. openerp-web +#: code:addons/web_pivot_computed_measure/static/src/dropdown_item_custom_measure/dropdown_item_custom_measure.xml:0 +#, python-format +msgid "Formula" +msgstr "" + +#. module: web_pivot_computed_measure +#. openerp-web +#: code:addons/web_pivot_computed_measure/static/src/dropdown_item_custom_measure/dropdown_item_custom_measure.xml:0 +#, python-format +msgid "Integer" +msgstr "" + +#. module: web_pivot_computed_measure +#. openerp-web +#: code:addons/web_pivot_computed_measure/static/src/dropdown_item_custom_measure/dropdown_item_custom_measure.xml:0 +#, python-format +msgid "Measure 1" +msgstr "" + +#. module: web_pivot_computed_measure +#. openerp-web +#: code:addons/web_pivot_computed_measure/static/src/dropdown_item_custom_measure/dropdown_item_custom_measure.xml:0 +#, python-format +msgid "Measure 2" +msgstr "" + +#. module: web_pivot_computed_measure +#. openerp-web +#: code:addons/web_pivot_computed_measure/static/src/dropdown_item_custom_measure/dropdown_item_custom_measure.xml:0 +#, python-format +msgid "Mult (m1 * m2)" +msgstr "" + +#. module: web_pivot_computed_measure +#. openerp-web +#: code:addons/web_pivot_computed_measure/static/src/dropdown_item_custom_measure/dropdown_item_custom_measure.xml:0 +#, python-format +msgid "Name" +msgstr "" + +#. module: web_pivot_computed_measure +#. openerp-web +#: code:addons/web_pivot_computed_measure/static/src/dropdown_item_custom_measure/dropdown_item_custom_measure.xml:0 +#, python-format +msgid "Operation" +msgstr "" + +#. module: web_pivot_computed_measure +#. openerp-web +#: code:addons/web_pivot_computed_measure/static/src/dropdown_item_custom_measure/dropdown_item_custom_measure.xml:0 +#, python-format +msgid "Perc (m1 * 100 / m2)" +msgstr "" + +#. module: web_pivot_computed_measure +#. openerp-web +#: code:addons/web_pivot_computed_measure/static/src/dropdown_item_custom_measure/dropdown_item_custom_measure.xml:0 +#, python-format +msgid "Percentage" +msgstr "" + +#. module: web_pivot_computed_measure +#. openerp-web +#: code:addons/web_pivot_computed_measure/static/src/dropdown_item_custom_measure/dropdown_item_custom_measure.xml:0 +#, python-format +msgid "Sub (m1 - m2)" +msgstr "" + +#. module: web_pivot_computed_measure +#. openerp-web +#: code:addons/web_pivot_computed_measure/static/src/dropdown_item_custom_measure/dropdown_item_custom_measure.xml:0 +#, python-format +msgid "Sum (m1 + m2)" +msgstr "" + +#. module: web_pivot_computed_measure +#. openerp-web +#: code:addons/web_pivot_computed_measure/static/src/pivot/pivot_model.esm.js:0 +#, python-format +msgid "" +"This measure is currently used by a 'computed measure'. Please, disable the " +"computed measure first." +msgstr "" diff --git a/web_pivot_computed_measure/readme/CONTRIBUTORS.rst b/web_pivot_computed_measure/readme/CONTRIBUTORS.rst new file mode 100644 index 000000000..52470bff0 --- /dev/null +++ b/web_pivot_computed_measure/readme/CONTRIBUTORS.rst @@ -0,0 +1,6 @@ +* `Tecnativa `_: + + * Alexandre D. Díaz + * Pedro M. Baeza + * Ernesto Tejeda + * Carlos Roca diff --git a/web_pivot_computed_measure/readme/DESCRIPTION.rst b/web_pivot_computed_measure/readme/DESCRIPTION.rst new file mode 100644 index 000000000..c48768ca0 --- /dev/null +++ b/web_pivot_computed_measure/readme/DESCRIPTION.rst @@ -0,0 +1 @@ +Adds support for computed measures on the pivot view. diff --git a/web_pivot_computed_measure/readme/ROADMAP.rst b/web_pivot_computed_measure/readme/ROADMAP.rst new file mode 100644 index 000000000..8e4604028 --- /dev/null +++ b/web_pivot_computed_measure/readme/ROADMAP.rst @@ -0,0 +1,2 @@ +#. Add support to define a style for a computed measure (ex. colored) +#. Use t-model to data-binding instead of jquery selectors diff --git a/web_pivot_computed_measure/readme/USAGE.rst b/web_pivot_computed_measure/readme/USAGE.rst new file mode 100644 index 000000000..02f354433 --- /dev/null +++ b/web_pivot_computed_measure/readme/USAGE.rst @@ -0,0 +1,25 @@ +Go to pivot view and click on the "Measures" menu, you will see +a new option called 'Computed Measure'. + +You have the follow options to create a 'computed measure': + - Measure 1: Used in 'operation formula' as 'm1' + - Measure 2: Used in 'operation formula' as 'm2' + - Operation: The formula + - Sum: m1 + m2 + - Sub: m1 - m2 + - Mult: m1 * m2 + - Div: m1 / m2 (Format: Float) + - Perc m1 / m2 (Format: Percentage) + - Custom: Special option only visible in debug mode to write a custom formula. + - Name: The name of the new measure (emtpy = auto-generated) + - Format: How will the value be printed + - Integer + - Float + - Percentage (value * 100) + - Formula*: Custom operation formula + These formula is evaluated using 'PY.eval' + +These computed measures can be mixed (You can reuse it to make new computed measures) and saved as favorites. + +Notice that "measures/computed measures" involved in an active 'computed measure' +can't be deactivated until you have deactivate the 'computed measure'. diff --git a/web_pivot_computed_measure/static/description/icon.png b/web_pivot_computed_measure/static/description/icon.png new file mode 100644 index 000000000..3a0328b51 Binary files /dev/null and b/web_pivot_computed_measure/static/description/icon.png differ diff --git a/web_pivot_computed_measure/static/description/index.html b/web_pivot_computed_measure/static/description/index.html new file mode 100644 index 000000000..7353f3434 --- /dev/null +++ b/web_pivot_computed_measure/static/description/index.html @@ -0,0 +1,483 @@ + + + + + + +Web Pivot Computed Measure + + + +
+

Web Pivot Computed Measure

+ + +

Beta License: AGPL-3 OCA/web Translate me on Weblate Try me on Runboat

+

Adds support for computed measures on the pivot view.

+

Table of contents

+ +
+

Usage

+

Go to pivot view and click on the “Measures” menu, you will see +a new option called ‘Computed Measure’.

+
+
You have the follow options to create a ‘computed measure’:
+
    +
  • Measure 1: Used in ‘operation formula’ as ‘m1’
  • +
  • Measure 2: Used in ‘operation formula’ as ‘m2’
  • +
  • +
    Operation: The formula
    +
      +
    • Sum: m1 + m2
    • +
    • Sub: m1 - m2
    • +
    • Mult: m1 * m2
    • +
    • Div: m1 / m2 (Format: Float)
    • +
    • Perc m1 / m2 (Format: Percentage)
    • +
    • Custom: Special option only visible in debug mode to write a custom formula.
    • +
    +
    +
    +
  • +
  • Name: The name of the new measure (emtpy = auto-generated)
  • +
  • +
    Format: How will the value be printed
    +
      +
    • Integer
    • +
    • Float
    • +
    • Percentage (value * 100)
    • +
    +
    +
    +
  • +
  • +
    Formula*: Custom operation formula
    +
    These formula is evaluated using ‘PY.eval’
    +
    +
  • +
+
+
+

These computed measures can be mixed (You can reuse it to make new computed measures) and saved as favorites.

+

Notice that “measures/computed measures” involved in an active ‘computed measure’ +can’t be deactivated until you have deactivate the ‘computed measure’.

+
+
+

Known issues / Roadmap

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

Bug Tracker

+

Bugs are tracked on GitHub Issues. +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 +feedback.

+

Do not contact contributors directly about support or help with technical issues.

+
+
+

Credits

+
+

Authors

+
    +
  • Tecnativa
  • +
+
+
+

Contributors

+
    +
  • Tecnativa:
      +
    • Alexandre D. Díaz
    • +
    • Pedro M. Baeza
    • +
    • Ernesto Tejeda
    • +
    • Carlos Roca
    • +
    +
  • +
+
+
+

Maintainers

+

This module is maintained by the OCA.

+Odoo Community Association +

OCA, or the Odoo Community Association, is a nonprofit organization whose +mission is to support the collaborative development of Odoo features and +promote its widespread use.

+

Current maintainer:

+

CarlosRoca13

+

This module is part of the OCA/web project on GitHub.

+

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

+
+
+
+ + diff --git a/web_pivot_computed_measure/static/src/dropdown_item_custom_measure/dropdown_item_custom_measure.esm.js b/web_pivot_computed_measure/static/src/dropdown_item_custom_measure/dropdown_item_custom_measure.esm.js new file mode 100644 index 000000000..e6a9259cd --- /dev/null +++ b/web_pivot_computed_measure/static/src/dropdown_item_custom_measure/dropdown_item_custom_measure.esm.js @@ -0,0 +1,49 @@ +/** @odoo-module **/ +/* Copyright 2022 Tecnativa - Carlos Roca + * License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html) */ + +import {Component, useState} from "@odoo/owl"; + +/** + * @extends Component + */ +export class DropdownItemCustomMeasure extends Component { + setup() { + this.isOpen = useState({value: false}); + } + + onClickComputedMeasure() { + this.isOpen.value = !this.isOpen.value; + } + + addMeasure(ev) { + const $target = $(ev.target).closest("#add_computed_measure_wrapper"); + const id = new Date().getTime(); + const field1 = $target.find("#computed_measure_field_1").val(); + const field2 = $target.find("#computed_measure_field_2").val(); + let operation = $target.find("#computed_measure_operation").val(); + if (operation === "custom") { + operation = $target.find("#computed_measure_operation_custom").val(); + } + const name = $target.find("#computed_measure_name").val(); + const format = $target.find("#computed_measure_format").val(); + this.props.model.addComputedMeasure( + id, + field1, + field2, + operation, + name, + format + ); + // Click on measures button to close the modal and recompute the measures added + $(ev.target).closest(".dropdown").find(".dropdown-toggle").trigger("click"); + } +} +DropdownItemCustomMeasure.template = + "web_pivot_computed_measure.DropdownItemCustomMeasure"; +DropdownItemCustomMeasure.props = { + measures: Object, + // Set as model because this module can be extended to be used on views that + // uses Measures like the graph view. + model: Object, +}; diff --git a/web_pivot_computed_measure/static/src/dropdown_item_custom_measure/dropdown_item_custom_measure.scss b/web_pivot_computed_measure/static/src/dropdown_item_custom_measure/dropdown_item_custom_measure.scss new file mode 100644 index 000000000..514ef93df --- /dev/null +++ b/web_pivot_computed_measure/static/src/dropdown_item_custom_measure/dropdown_item_custom_measure.scss @@ -0,0 +1,9 @@ +#add_computed_measure_wrapper { + padding: 0 20px; + min-width: 300px; + white-space: nowrap; + .d-table-cell { + vertical-align: middle; + padding: 3px 0; + } +} diff --git a/web_pivot_computed_measure/static/src/dropdown_item_custom_measure/dropdown_item_custom_measure.xml b/web_pivot_computed_measure/static/src/dropdown_item_custom_measure/dropdown_item_custom_measure.xml new file mode 100644 index 000000000..a2bdc905d --- /dev/null +++ b/web_pivot_computed_measure/static/src/dropdown_item_custom_measure/dropdown_item_custom_measure.xml @@ -0,0 +1,160 @@ + + + + + + + + + + + + + + + + + + + + + + diff --git a/web_pivot_computed_measure/static/src/helpers/utils.esm.js b/web_pivot_computed_measure/static/src/helpers/utils.esm.js new file mode 100644 index 000000000..df95c84bc --- /dev/null +++ b/web_pivot_computed_measure/static/src/helpers/utils.esm.js @@ -0,0 +1,124 @@ +/** @odoo-module **/ +/* Copyright 2023 Tecnativa - Carlos Roca + * License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html) */ + +/** + * Function that traverse the text given character by character + * + * @param {String} text + * @returns {Array} + */ +function getTokensFromText(text) { + const symbols = ["+", "-", "*", "/", "(", ")"]; + const tokens = []; + let token = ""; + for (let i = 0; i < text.length; i++) { + const c = text[i]; + if (c === " ") continue; + if (symbols.includes(c)) { + if (token !== "") { + tokens.push(token); + token = ""; + } + tokens.push(c); + } else { + token += c; + } + } + if (token !== "") { + tokens.push(token); + } + return tokens; +} + +/** + * Function that executes an operation between the last two operands in the operands stack + * and the last operator in the operators stack, and saves the result in the operands stack. + * + * @param {Array} operands + * @param {Array} operators + */ +function executeOperation(operands, operators) { + const b = operands.pop(); + const a = operands.pop(); + const op = operators.pop(); + switch (op) { + case "+": + operands.push(a + b); + break; + case "-": + operands.push(a - b); + break; + case "*": + operands.push(a * b); + break; + case "/": + operands.push(a / b); + break; + } +} + +/** + * Function that returns the precedence of an operator + * + * @param {String} op + * @returns {Number} + */ +function precedence(op) { + if (op === "+" || op === "-") { + return 1; + } + if (op === "*" || op === "/") { + return 2; + } + if (op === "(" || op === ")") { + return 0; + } +} + +/** + * Helper function that takes a mathematical expression in text form and an object + * of variable values, evaluates the expression, and returns the result. + * + * @param {String} text + * @param {Object} values + * @returns {any} + */ +export function evalOperation(text, values) { + const tokens = getTokensFromText(text); + const operands = []; + const operators = []; + for (const token of tokens) { + if (!isNaN(token)) { + // If the token is a number, convert it to a number and add it to the operands stack + operands.push(Number(token)); + } else if (token in values) { + // If the token is a variable, get its value from the object and add it to the operands stack + operands.push(values[token]); + } else if (token === "(") { + // If the token is an open parenthesis, add it to the operators stack + operators.push(token); + } else if (token === ")") { + // If the token is a closing parenthesis, pop and execute operators from the stack until an open parenthesis is found + while (operators.length > 0 && operators[operators.length - 1] !== "(") { + executeOperation(operands, operators); + } + // Pop the open parenthesis from the operators stack + operators.pop(); + } else { + // If the token is an operator, pop and execute operators from the stack while they have equal or higher precedence than the token + while ( + operators.length > 0 && + precedence(operators[operators.length - 1]) >= precedence(token) + ) { + executeOperation(operands, operators); + } + // Add the token to the operators stack + operators.push(token); + } + } + while (operators.length > 0) { + executeOperation(operands, operators); + } + return operands.pop(); +} diff --git a/web_pivot_computed_measure/static/src/pivot/pivot_controller.esm.js b/web_pivot_computed_measure/static/src/pivot/pivot_controller.esm.js new file mode 100644 index 000000000..8fd29a265 --- /dev/null +++ b/web_pivot_computed_measure/static/src/pivot/pivot_controller.esm.js @@ -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, +}; diff --git a/web_pivot_computed_measure/static/src/pivot/pivot_model.esm.js b/web_pivot_computed_measure/static/src/pivot/pivot_model.esm.js new file mode 100644 index 000000000..96d09f668 --- /dev/null +++ b/web_pivot_computed_measure/static/src/pivot/pivot_model.esm.js @@ -0,0 +1,296 @@ +/** @odoo-module **/ +/* Copyright 2020 Tecnativa - Alexandre Díaz + * Copyright 2022 Tecnativa - Carlos Roca + * 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/core/utils/patch"; +import {computeReportMeasures} from "@web/views/utils"; +import {evalOperation} from "../helpers/utils.esm"; + +patch(PivotModel.prototype, "web_pivot_computed_measure.PivotModel", { + /** + * Add _computed_measures to avoid recompute them until page is recharged + * + * @override + */ + setup() { + this._super(...arguments); + this._computed_measures = []; + }, + + /** + * Create a new computed measure + * + * @param {String} id + * @param {String} field1 + * @param {String} field2 + * @param {String} operation + * @param {String} name + * @param {String} format + * @returns a promise + */ + addComputedMeasure(id, field1, field2, operation, name, format) { + const measure = _.find(this._computed_measures, (item) => { + return ( + item.field1 === field1 && + item.field2 === field2 && + item.operation === operation + ); + }); + if (measure) { + return Promise.resolve(); + } + const fieldM1 = this.metaData.fields[field1]; + const fieldM2 = this.metaData.fields[field2]; + const cmId = "__computed_" + id; + const oper = operation.replace(/m1/g, field1).replace(/m2/g, field2); + const oper_human = operation + .replace( + /m1/g, + fieldM1.__computed_id ? "(" + fieldM1.string + ")" : fieldM1.string + ) + .replace( + /m2/g, + fieldM2.__computed_id ? "(" + fieldM2.string + ")" : fieldM2.string + ); + const cmTotal = this._computed_measures.push({ + field1: field1, + field2: field2, + operation: oper, + name: name || oper_human, + id: cmId, + format: format, + }); + return this._createVirtualMeasure(this._computed_measures[cmTotal - 1]); + }, + + /** + * Create and enable a measure based on a 'fake' field + * + * @private + * @param {Object} cmDef + * @param {List} fields *Optional* + * @returns a promise + */ + _createVirtualMeasure(cmDef, fields) { + this._createVirtualField(cmDef, fields); + // Activate computed field + return this.toggleMeasure(cmDef.id); + }, + _createVirtualField(cmDef, fields, config) { + const arrFields = fields || this.metaData.fields; + // This is a minimal 'fake' field info + arrFields[cmDef.id] = { + // Used to format the value + type: cmDef.format, + // Used to print the header name + string: cmDef.name, + // Referenced on payload prop at DropdownItem, used to interact with + // created measures + name: cmDef.id, + // Used to know if is a computed measure field + __computed_id: cmDef.id, + // Operator used for group the measure added. + group_operator: "sum", + }; + const metaData = (config && config.metaData) || this.metaData; + metaData.measures[cmDef.id] = arrFields[cmDef.id]; + }, + /** + * Active the measures related to the 'fake' field + * + * @private + * @param {List of Strings} fields + */ + async _activeMeasures(fields) { + let needLoad = false; + for (const field of fields) { + if (await !this._isMeasureEnabled(field)) { + this.metaData.activeMeasures.push(field); + needLoad = true; + } + } + if (needLoad) { + const config = {metaData: this.metaData, data: this.data}; + + return this._loadData(config).then(() => { + // Notify changes to renderer for show it on the pivot view + this.notify(); + }); + } + return Promise.resolve(); + }, + + /** + * Check if the measure is enabled + * + * @private + * @param {String} field + */ + _isMeasureEnabled(field, config) { + const activeMeasures = + (config && config.metaData.activeMeasures) || + this.metaData.activeMeasures || + []; + return _.contains(activeMeasures, field); + }, + + /** + * Helper function to add computed measure fields data into a 'subGroupData' + * + * @private + * @param {Object} subGroupData + */ + _fillComputedMeasuresData(subGroupData, config) { + for (const cm of this._computed_measures) { + if (!this._isMeasureEnabled(cm.id, config)) continue; + if (subGroupData.__count === 0) { + subGroupData[cm.id] = false; + } else { + // eslint-disable-next-line no-undef + subGroupData[cm.id] = evalOperation(cm.operation, subGroupData); + } + } + }, + + /** + * Fill the groupSubdivisions with the computed measures and their values + * + * @override + */ + _prepareData(group, groupSubdivisions, config) { + for (const groupSubdivision of groupSubdivisions) { + for (const subGroup of groupSubdivision.subGroups) { + this._fillComputedMeasuresData(subGroup, config); + } + } + this._super(...arguments); + }, + + /** + * _getGroupSubdivision method invokes the read_group method of the + * model via rpc and the passed 'fields' argument is the list of + * measure names that is in this.metaData.activeMeasures, so we remove the + * computed measures form this.metaData.activeMeasures before calling _super + * to prevent any possible exception. + * + * @override + */ + _getGroupSubdivision(group, rowGroupBy, colGroupBy, config) { + const computed_measures = []; + for (let i = 0; i < config.metaData.activeMeasures.length; i++) + if (config.metaData.activeMeasures[i].startsWith("__computed_")) { + computed_measures.push(config.metaData.activeMeasures[i]); + config.metaData.activeMeasures.splice(i, 1); + i--; + } + const res = this._super(...arguments); + $.merge(config.metaData.activeMeasures, computed_measures); + return res; + }, + + /** + * Adds a rule to deny that measures can be disabled if are being used by a computed measure. + * In the other hand, when enables a measure analyzes it to active all involved measures. + * + * @override + */ + toggleMeasure(fieldName) { + if (this._isMeasureEnabled(fieldName)) { + // Mesaure is enabled + const umeasures = _.filter(this._computed_measures, (item) => { + return item.field1 === fieldName || item.field2 === fieldName; + }); + if (umeasures.length && this._isMeasureEnabled(umeasures[0].id)) { + return Promise.reject( + this.env._t( + "This measure is currently used by a 'computed measure'. Please, disable the computed measure first." + ) + ); + } + } else { + // Measure is disabled + const toEnable = []; + const toAnalyze = [fieldName]; + while (toAnalyze.length) { + // Analyze all items involved on computed measures to enable them + const afield = toAnalyze.shift(); + const fieldDef = this.metaData.fields[afield]; + // Need to check if fieldDef exists to avoid problems with __count + if (fieldDef && fieldDef.__computed_id) { + const cm = _.find(this._computed_measures, { + id: fieldDef.__computed_id, + }); + toAnalyze.push(cm.field1, cm.field2); + const toEnableFields = []; + if (!this.metaData.fields[cm.field1].__computed_id) { + toEnableFields.push(cm.field1); + } + if (!this.metaData.fields[cm.field2].__computed_id) { + toEnableFields.push(cm.field2); + } + toEnableFields.push(afield); + toEnable.push(toEnableFields); + } + } + if (toEnable.length) { + this._activeMeasures( + // Transform the array of arrays to a simple array. + // [1, [2, 3]] => [1, 2, 3] + _.flatten(toEnable.reverse()) + ); + } + } + return this._super(...arguments); + }, + /** + * Load the measures added to selected favorite filters + * + * @override + */ + async load(searchParams) { + var _super = this._super.bind(this); + var config = {metaData: this.metaData, data: this.data}; + if (!this.metaData.measures) { + const metaData = this._buildMetaData(); + metaData.measures = computeReportMeasures( + metaData.fields, + metaData.fieldAttrs, + metaData.activeMeasures, + metaData.additionalMeasures + ); + config = {metaData, data: this.data}; + } + if ("context" in searchParams) { + this._computed_measures = + searchParams.context.pivot_computed_measures || + searchParams.computed_measures || + []; + } + for (const cmDef of this._computed_measures) { + if (this._isMeasureEnabled(cmDef.id, config)) { + continue; + } + await this._createVirtualField(cmDef, undefined, config); + } + const fieldNames = Object.keys(this.metaData.fields); + for (const fieldName of fieldNames) { + const field = this.metaData.fields[fieldName]; + if (field.__computed_id) { + const cm = _.find(this._computed_measures, { + id: field.__computed_id, + }); + if (!cm) { + delete this.metaData.fields[fieldName]; + delete this.metaData.measures[fieldName]; + this.metaData.activeMeasures = _.without( + this.metaData.activeMeasures, + fieldName + ); + } + } + } + return _super(...arguments); + }, +}); diff --git a/web_pivot_computed_measure/static/src/pivot/pivot_renderer.esm.js b/web_pivot_computed_measure/static/src/pivot/pivot_renderer.esm.js new file mode 100644 index 000000000..3987dc852 --- /dev/null +++ b/web_pivot_computed_measure/static/src/pivot/pivot_renderer.esm.js @@ -0,0 +1,15 @@ +/** @odoo-module **/ +/* Copyright 2022 Tecnativa - Carlos Roca + * 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/core/utils/patch"; + +patch(PivotRenderer.prototype, "web_pivot_computed_measure.PivotRenderer", { + getFormattedValue(cell) { + if (cell.value === Infinity) { + return "-"; + } + return this._super(...arguments); + }, +}); diff --git a/web_pivot_computed_measure/static/src/pivot/pivot_view.xml b/web_pivot_computed_measure/static/src/pivot/pivot_view.xml new file mode 100644 index 000000000..b8ae60aaf --- /dev/null +++ b/web_pivot_computed_measure/static/src/pivot/pivot_view.xml @@ -0,0 +1,9 @@ + + + + + + + + + diff --git a/web_pivot_computed_measure/static/src/test/test.esm.js b/web_pivot_computed_measure/static/src/test/test.esm.js new file mode 100644 index 000000000..25b0ed0a4 --- /dev/null +++ b/web_pivot_computed_measure/static/src/test/test.esm.js @@ -0,0 +1,67 @@ +/** @odoo-module **/ +/* Copyright 2022 Tecnativa - Carlos Roca + * License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html) */ + +import tour from "web_tour.tour"; + +tour.register( + "web_pivot_computed_measure_tour", + { + url: "/web", + test: true, + }, + [ + { + trigger: ".o_navbar_apps_menu button", + }, + { + trigger: '.o_app[data-menu-xmlid="base.menu_administration"]', + }, + { + trigger: 'button[data-menu-xmlid="base.menu_users"]', + }, + { + trigger: 'a[data-menu-xmlid="base.menu_action_res_users"]', + }, + { + trigger: "button.o_pivot", + }, + { + trigger: 'button:contains(" Measures ")', + }, + { + trigger: 'a:contains(" Computed Measure ")', + }, + { + trigger: "select#computed_measure_field_1", + run: "text user_year_now", + }, + { + trigger: "select#computed_measure_field_2", + run: "text user_year_born", + }, + { + trigger: "select#computed_measure_operation", + run: "text m1-m2", + }, + { + trigger: "select#computed_measure_format", + run: "text integer", + }, + { + trigger: "button.o_add_computed_measure", + }, + { + trigger: 'th.o_pivot_measure_row:contains("User Year Now")', + extra_trigger: 'div.o_value:contains("2,022")', + }, + { + trigger: 'th.o_pivot_measure_row:contains("User Year Born")', + extra_trigger: 'div.o_value:contains("1,998")', + }, + { + trigger: 'th.o_pivot_measure_row:contains("User Year Now-User Year Born")', + extra_trigger: 'div.o_value:contains("24")', + }, + ] +); diff --git a/web_pivot_computed_measure/static/src/view.xml b/web_pivot_computed_measure/static/src/view.xml new file mode 100644 index 000000000..20da6cd4b --- /dev/null +++ b/web_pivot_computed_measure/static/src/view.xml @@ -0,0 +1,25 @@ + + + + + !measure.startsWith('__computed_') + + +