From 9533a8fa8b5d9d9327597f72231d90d7be721552 Mon Sep 17 00:00:00 2001 From: CarlosRoca13 Date: Tue, 22 Nov 2022 13:46:39 +0100 Subject: [PATCH] [MIG] web_pivot_computed_measure: Migration to 15.0 --- web_pivot_computed_measure/README.rst | 12 +- web_pivot_computed_measure/__manifest__.py | 18 +- web_pivot_computed_measure/i18n/es.po | 52 ++-- .../i18n/web_pivot_computed_measure.pot | 47 +-- .../readme/CONTRIBUTORS.rst | 1 + web_pivot_computed_measure/readme/ROADMAP.rst | 1 + .../static/description/index.html | 8 +- .../dropdown_item_custom_measure.esm.js | 51 +++ .../dropdown_item_custom_measure.scss} | 0 .../dropdown_item_custom_measure.xml} | 62 ++-- .../static/src/js/pivot_controller.js | 198 ------------ .../static/src/js/pivot_model.js | 294 ------------------ .../static/src/pivot/pivot_model.esm.js | 238 ++++++++++++++ .../static/src/pivot/pivot_view.xml | 9 + .../static/src/test/test.esm.js | 65 ++++ .../static/src/view.xml | 27 ++ web_pivot_computed_measure/tests/__init__.py | 1 + .../tests/res_users_fake.py | 12 + .../tests/test_ui_pivot.py | 37 +++ web_pivot_computed_measure/view/assets.xml | 19 -- 20 files changed, 557 insertions(+), 595 deletions(-) create mode 100644 web_pivot_computed_measure/static/src/dropdown_item_custom_measure/dropdown_item_custom_measure.esm.js rename web_pivot_computed_measure/static/src/{scss/web_pivot_computed_measure.scss => dropdown_item_custom_measure/dropdown_item_custom_measure.scss} (100%) rename web_pivot_computed_measure/static/src/{xml/web_pivot_computed_measure.xml => dropdown_item_custom_measure/dropdown_item_custom_measure.xml} (77%) delete mode 100644 web_pivot_computed_measure/static/src/js/pivot_controller.js delete mode 100644 web_pivot_computed_measure/static/src/js/pivot_model.js create mode 100644 web_pivot_computed_measure/static/src/pivot/pivot_model.esm.js create mode 100644 web_pivot_computed_measure/static/src/pivot/pivot_view.xml create mode 100644 web_pivot_computed_measure/static/src/test/test.esm.js create mode 100644 web_pivot_computed_measure/static/src/view.xml create mode 100644 web_pivot_computed_measure/tests/__init__.py create mode 100644 web_pivot_computed_measure/tests/res_users_fake.py create mode 100644 web_pivot_computed_measure/tests/test_ui_pivot.py delete mode 100644 web_pivot_computed_measure/view/assets.xml diff --git a/web_pivot_computed_measure/README.rst b/web_pivot_computed_measure/README.rst index f124524fe..4e7a16a8c 100644 --- a/web_pivot_computed_measure/README.rst +++ b/web_pivot_computed_measure/README.rst @@ -14,13 +14,13 @@ Web Pivot Computed Measure :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/13.0/web_pivot_computed_measure + :target: https://github.com/OCA/web/tree/15.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-13-0/web-13-0-web_pivot_computed_measure + :target: https://translation.odoo-community.org/projects/web-15-0/web-15-0-web_pivot_computed_measure :alt: Translate me on Weblate .. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png - :target: https://runbot.odoo-community.org/runbot/162/13.0 + :target: https://runbot.odoo-community.org/runbot/162/15.0 :alt: Try me on Runbot |badge1| |badge2| |badge3| |badge4| |badge5| @@ -65,6 +65,7 @@ Known issues / Roadmap ====================== #. Add support to define a style for a computed measure (ex. colored) +#. Use t-model to data-binding instad of jquery selectors Bug Tracker =========== @@ -72,7 +73,7 @@ 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 smashing it by providing a detailed and welcomed -`feedback `_. +`feedback `_. Do not contact contributors directly about support or help with technical issues. @@ -92,6 +93,7 @@ Contributors * Alexandre D. Díaz * Pedro M. Baeza * Ernesto Tejeda + * Carlos Roca Maintainers ~~~~~~~~~~~ @@ -106,6 +108,6 @@ 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. -This module is part of the `OCA/web `_ project on GitHub. +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/__manifest__.py b/web_pivot_computed_measure/__manifest__.py index c55cc3d00..c6d618203 100644 --- a/web_pivot_computed_measure/__manifest__.py +++ b/web_pivot_computed_measure/__manifest__.py @@ -1,16 +1,26 @@ # 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": "13.0.1.1.0", + "version": "15.0.1.0.0", "author": "Tecnativa, Odoo Community Association (OCA)", "license": "AGPL-3", "website": "https://github.com/OCA/web", "depends": ["web"], - "data": ["view/assets.xml"], - "qweb": ["static/src/xml/web_pivot_computed_measure.xml"], "auto_install": False, "installable": True, + "assets": { + "web.assets_qweb": [ + "/web_pivot_computed_measure/static/src/**/*.xml", + ], + "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.assets_tests": [ + "/web_pivot_computed_measure/static/src/test/test.esm.js", + ], + }, } diff --git a/web_pivot_computed_measure/i18n/es.po b/web_pivot_computed_measure/i18n/es.po index adb3cded6..4b375526c 100644 --- a/web_pivot_computed_measure/i18n/es.po +++ b/web_pivot_computed_measure/i18n/es.po @@ -6,145 +6,153 @@ msgid "" msgstr "" "Project-Id-Version: Odoo Server 12.0\n" "Report-Msgid-Bugs-To: \n" -"PO-Revision-Date: 2020-09-16 14:00+0000\n" +"POT-Creation-Date: 2022-11-22 12:42+0000\n" +"PO-Revision-Date: 2022-11-22 13:43+0100\n" "Last-Translator: claudiagn \n" "Language-Team: none\n" "Language: es\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" -"Content-Transfer-Encoding: \n" +"Content-Transfer-Encoding: 8bit\n" "Plural-Forms: nplurals=2; plural=n != 1;\n" -"X-Generator: Weblate 3.10\n" +"X-Generator: Poedit 2.3\n" #. module: web_pivot_computed_measure #. openerp-web -#: code:addons/web_pivot_computed_measure/static/src/xml/web_pivot_computed_measure.xml:0 +#: 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 "Añadir" #. module: web_pivot_computed_measure #. openerp-web -#: code:addons/web_pivot_computed_measure/static/src/xml/web_pivot_computed_measure.xml:0 +#: 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/xml/web_pivot_computed_measure.xml:0 +#: 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/xml/web_pivot_computed_measure.xml:0 +#: 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/xml/web_pivot_computed_measure.xml:0 +#: 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/xml/web_pivot_computed_measure.xml:0 +#: 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/xml/web_pivot_computed_measure.xml:0 +#: 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/xml/web_pivot_computed_measure.xml:0 +#: 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/xml/web_pivot_computed_measure.xml:0 +#: 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/xml/web_pivot_computed_measure.xml:0 +#: 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/xml/web_pivot_computed_measure.xml:0 +#: 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/xml/web_pivot_computed_measure.xml:0 +#: 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/xml/web_pivot_computed_measure.xml:0 +#: 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/xml/web_pivot_computed_measure.xml:0 +#: 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/xml/web_pivot_computed_measure.xml:0 +#: 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/xml/web_pivot_computed_measure.xml:0 +#: 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/xml/web_pivot_computed_measure.xml:0 +#: 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/xml/web_pivot_computed_measure.xml:0 +#: 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/js/pivot_model.js:0 +#: code:addons/web_pivot_computed_measure/static/src/pivot/pivot_model.js:0 #, python-format msgid "" "This measure is currently used by a 'computed measure'. Please, disable the " diff --git a/web_pivot_computed_measure/i18n/web_pivot_computed_measure.pot b/web_pivot_computed_measure/i18n/web_pivot_computed_measure.pot index 6700b3276..117534c76 100644 --- a/web_pivot_computed_measure/i18n/web_pivot_computed_measure.pot +++ b/web_pivot_computed_measure/i18n/web_pivot_computed_measure.pot @@ -4,7 +4,7 @@ # msgid "" msgstr "" -"Project-Id-Version: Odoo Server 13.0\n" +"Project-Id-Version: Odoo Server 15.0\n" "Report-Msgid-Bugs-To: \n" "Last-Translator: \n" "Language-Team: \n" @@ -15,133 +15,140 @@ msgstr "" #. module: web_pivot_computed_measure #. openerp-web -#: code:addons/web_pivot_computed_measure/static/src/xml/web_pivot_computed_measure.xml:0 +#: 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/xml/web_pivot_computed_measure.xml:0 +#: 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/xml/web_pivot_computed_measure.xml:0 +#: 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/xml/web_pivot_computed_measure.xml:0 +#: 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/xml/web_pivot_computed_measure.xml:0 +#: 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/xml/web_pivot_computed_measure.xml:0 +#: 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/xml/web_pivot_computed_measure.xml:0 +#: 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/xml/web_pivot_computed_measure.xml:0 +#: 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/xml/web_pivot_computed_measure.xml:0 +#: 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/xml/web_pivot_computed_measure.xml:0 +#: 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/xml/web_pivot_computed_measure.xml:0 +#: 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/xml/web_pivot_computed_measure.xml:0 +#: 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/xml/web_pivot_computed_measure.xml:0 +#: 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/xml/web_pivot_computed_measure.xml:0 +#: 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/xml/web_pivot_computed_measure.xml:0 +#: 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/xml/web_pivot_computed_measure.xml:0 +#: 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/xml/web_pivot_computed_measure.xml:0 +#: 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/xml/web_pivot_computed_measure.xml:0 +#: 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/js/pivot_model.js:0 +#: 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 " diff --git a/web_pivot_computed_measure/readme/CONTRIBUTORS.rst b/web_pivot_computed_measure/readme/CONTRIBUTORS.rst index ea8b8e058..52470bff0 100644 --- a/web_pivot_computed_measure/readme/CONTRIBUTORS.rst +++ b/web_pivot_computed_measure/readme/CONTRIBUTORS.rst @@ -3,3 +3,4 @@ * Alexandre D. Díaz * Pedro M. Baeza * Ernesto Tejeda + * Carlos Roca diff --git a/web_pivot_computed_measure/readme/ROADMAP.rst b/web_pivot_computed_measure/readme/ROADMAP.rst index af507d470..453971d1b 100644 --- a/web_pivot_computed_measure/readme/ROADMAP.rst +++ b/web_pivot_computed_measure/readme/ROADMAP.rst @@ -1 +1,2 @@ #. Add support to define a style for a computed measure (ex. colored) +#. Use t-model to data-binding instad of jquery selectors diff --git a/web_pivot_computed_measure/static/description/index.html b/web_pivot_computed_measure/static/description/index.html index bf68e1601..cf9c32d4a 100644 --- a/web_pivot_computed_measure/static/description/index.html +++ b/web_pivot_computed_measure/static/description/index.html @@ -367,7 +367,7 @@ ul.auto-toc { !! This file is generated by oca-gen-addon-readme !! !! changes will be overwritten. !! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! --> -

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

+

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

Adds support for computed measures on the pivot view.

Table of contents

@@ -432,6 +432,7 @@ 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 instad of jquery selectors
@@ -439,7 +440,7 @@ can’t be deactivated until you have deactivate the ‘computed measure’.

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 smashing it by providing a detailed and welcomed -feedback.

+feedback.

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

@@ -457,6 +458,7 @@ If you spotted it first, help us smashing it by providing a detailed and welcome
  • Alexandre D. Díaz
  • Pedro M. Baeza
  • Ernesto Tejeda
  • +
  • Carlos Roca
  • @@ -468,7 +470,7 @@ If you spotted it first, help us smashing it by providing a detailed and welcome

    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.

    -

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

    +

    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..3469e386f --- /dev/null +++ b/web_pivot_computed_measure/static/src/dropdown_item_custom_measure/dropdown_item_custom_measure.esm.js @@ -0,0 +1,51 @@ +/** @odoo-module **/ +/* 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; + +/** + * @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, +}; +QWeb.registerComponent("DropdownItemCustomMeasure", DropdownItemCustomMeasure); diff --git a/web_pivot_computed_measure/static/src/scss/web_pivot_computed_measure.scss b/web_pivot_computed_measure/static/src/dropdown_item_custom_measure/dropdown_item_custom_measure.scss similarity index 100% rename from web_pivot_computed_measure/static/src/scss/web_pivot_computed_measure.scss rename to web_pivot_computed_measure/static/src/dropdown_item_custom_measure/dropdown_item_custom_measure.scss diff --git a/web_pivot_computed_measure/static/src/xml/web_pivot_computed_measure.xml b/web_pivot_computed_measure/static/src/dropdown_item_custom_measure/dropdown_item_custom_measure.xml similarity index 77% rename from web_pivot_computed_measure/static/src/xml/web_pivot_computed_measure.xml rename to web_pivot_computed_measure/static/src/dropdown_item_custom_measure/dropdown_item_custom_measure.xml index a00fff183..a2bdc905d 100644 --- a/web_pivot_computed_measure/static/src/xml/web_pivot_computed_measure.xml +++ b/web_pivot_computed_measure/static/src/dropdown_item_custom_measure/dropdown_item_custom_measure.xml @@ -1,10 +1,6 @@ - - - + + @@ -24,7 +20,8 @@ License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). Custom - + + @@ -35,30 +32,19 @@ License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). Percentage - -