diff --git a/.copier-answers.yml b/.copier-answers.yml index 6ae3d3057f71..2053f2ee6670 100644 --- a/.copier-answers.yml +++ b/.copier-answers.yml @@ -1,5 +1,5 @@ # Do NOT update manually; changes here will be overwritten by Copier -_commit: v1.32 +_commit: v1.36 _src_path: git+https://github.com/OCA/oca-addons-repo-template additional_ruff_rules: [] ci: GitHub diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 000000000000..e0d56685a954 --- /dev/null +++ b/.gitattributes @@ -0,0 +1 @@ +test-requirements.txt merge=union diff --git a/.github/workflows/pre-commit.yml b/.github/workflows/pre-commit.yml index 5eb021ef153c..852a07469b2e 100644 --- a/.github/workflows/pre-commit.yml +++ b/.github/workflows/pre-commit.yml @@ -17,6 +17,7 @@ jobs: - uses: actions/setup-python@v5 with: python-version: "3.11" + cache: 'pip' - name: Get python version run: echo "PY=$(python -VV | sha256sum | cut -d' ' -f1)" >> $GITHUB_ENV - uses: actions/cache@v4 diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 6032014807ea..5df33daee45e 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -51,7 +51,7 @@ jobs: makepot: "true" services: postgres: - image: postgres:12.0 + image: postgres:12 env: POSTGRES_USER: odoo POSTGRES_PASSWORD: odoo @@ -76,6 +76,13 @@ jobs: run: oca_init_test_database - name: Run tests run: oca_run_tests + - name: Upload screenshots from JS tests + uses: actions/upload-artifact@v4 + if: ${{ failure() }} + with: + name: Screenshots of failed JS tests - ${{ matrix.name }}${{ join(matrix.include) }} + path: /tmp/odoo_tests/${{ env.PGDATABASE }} + if-no-files-found: ignore - uses: codecov/codecov-action@v4 with: token: ${{ secrets.CODECOV_TOKEN }} diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 9fc02859e158..3054c9f3f23e 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -39,11 +39,11 @@ repos: language: fail files: '[a-zA-Z0-9_]*/i18n/en\.po$' - repo: https://github.com/sbidoul/whool - rev: v1.2 + rev: v1.3 hooks: - id: whool-init - repo: https://github.com/oca/maintainer-tools - rev: bf9ecb9938b6a5deca0ff3d870fbd3f33341fded + rev: b89f767503be6ab2b11e4f50a7557cb20066e667 hooks: # update the NOT INSTALLABLE ADDONS section above - id: oca-update-pre-commit-excluded-addons diff --git a/.pylintrc b/.pylintrc index 7c62b6d2edde..197cb673705b 100644 --- a/.pylintrc +++ b/.pylintrc @@ -25,19 +25,25 @@ disable=all enable=anomalous-backslash-in-string, api-one-deprecated, api-one-multi-together, - assignment-from-none, - attribute-deprecated, class-camelcase, - dangerous-default-value, dangerous-view-replace-wo-priority, - development-status-allowed, duplicate-id-csv, - duplicate-key, duplicate-xml-fields, duplicate-xml-record-id, eval-referenced, - eval-used, incoherent-interpreter-exec-perm, + openerp-exception-warning, + redundant-modulename-xml, + relative-import, + rst-syntax-error, + wrong-tabs-instead-of-spaces, + xml-syntax-error, + assignment-from-none, + attribute-deprecated, + dangerous-default-value, + development-status-allowed, + duplicate-key, + eval-used, license-allowed, manifest-author-string, manifest-deprecated-key, @@ -48,73 +54,68 @@ enable=anomalous-backslash-in-string, method-inverse, method-required-super, method-search, - openerp-exception-warning, pointless-statement, pointless-string-statement, print-used, redundant-keyword-arg, - redundant-modulename-xml, reimported, - relative-import, return-in-init, - rst-syntax-error, sql-injection, too-few-format-args, translation-field, translation-required, unreachable, use-vim-comment, - wrong-tabs-instead-of-spaces, - xml-syntax-error, - attribute-string-redundant, character-not-valid-in-resource-link, - consider-merging-classes-inherited, - context-overridden, create-user-wo-reset-password, dangerous-filter-wo-user, dangerous-qweb-replace-wo-priority, deprecated-data-xml-node, deprecated-openerp-xml-node, duplicate-po-message-definition, - except-pass, file-not-used, + missing-newline-extrafiles, + old-api7-method-defined, + po-msgstr-variables, + po-syntax-error, + str-format-used, + unnecessary-utf8-coding-comment, + xml-attribute-translatable, + xml-deprecated-qweb-directive, + xml-deprecated-tree-attribute, + attribute-string-redundant, + consider-merging-classes-inherited, + context-overridden, + except-pass, invalid-commit, manifest-maintainers-list, - missing-newline-extrafiles, missing-readme, missing-return, odoo-addons-relative-import, - old-api7-method-defined, - po-msgstr-variables, - po-syntax-error, renamed-field-parameter, resource-not-exist, - str-format-used, test-folder-imported, translation-contains-variable, translation-positional-used, - unnecessary-utf8-coding-comment, website-manifest-key-not-valid-uri, - xml-attribute-translatable, - xml-deprecated-qweb-directive, - xml-deprecated-tree-attribute, external-request-timeout, - # messages that do not cause the lint step to fail - consider-merging-classes-inherited, + missing-manifest-dependency, + too-complex,, create-user-wo-reset-password, dangerous-filter-wo-user, - deprecated-module, file-not-used, - invalid-commit, - missing-manifest-dependency, missing-newline-extrafiles, - missing-readme, no-utf8-coding-comment, - odoo-addons-relative-import, old-api7-method-defined, + unnecessary-utf8-coding-comment, + # messages that do not cause the lint step to fail + consider-merging-classes-inherited, + deprecated-module, + invalid-commit, + missing-readme, + odoo-addons-relative-import, redefined-builtin, - too-complex, - unnecessary-utf8-coding-comment + manifest-external-assets [REPORTS] diff --git a/.pylintrc-mandatory b/.pylintrc-mandatory index 018fd61cdd70..73674c04d426 100644 --- a/.pylintrc-mandatory +++ b/.pylintrc-mandatory @@ -17,19 +17,25 @@ disable=all enable=anomalous-backslash-in-string, api-one-deprecated, api-one-multi-together, - assignment-from-none, - attribute-deprecated, class-camelcase, - dangerous-default-value, dangerous-view-replace-wo-priority, - development-status-allowed, duplicate-id-csv, - duplicate-key, duplicate-xml-fields, duplicate-xml-record-id, eval-referenced, - eval-used, incoherent-interpreter-exec-perm, + openerp-exception-warning, + redundant-modulename-xml, + relative-import, + rst-syntax-error, + wrong-tabs-instead-of-spaces, + xml-syntax-error, + assignment-from-none, + attribute-deprecated, + dangerous-default-value, + development-status-allowed, + duplicate-key, + eval-used, license-allowed, manifest-author-string, manifest-deprecated-key, @@ -40,56 +46,50 @@ enable=anomalous-backslash-in-string, method-inverse, method-required-super, method-search, - openerp-exception-warning, pointless-statement, pointless-string-statement, print-used, redundant-keyword-arg, - redundant-modulename-xml, reimported, - relative-import, return-in-init, - rst-syntax-error, sql-injection, too-few-format-args, translation-field, translation-required, unreachable, use-vim-comment, - wrong-tabs-instead-of-spaces, - xml-syntax-error, - attribute-string-redundant, character-not-valid-in-resource-link, - consider-merging-classes-inherited, - context-overridden, create-user-wo-reset-password, dangerous-filter-wo-user, dangerous-qweb-replace-wo-priority, deprecated-data-xml-node, deprecated-openerp-xml-node, duplicate-po-message-definition, - except-pass, file-not-used, + missing-newline-extrafiles, + old-api7-method-defined, + po-msgstr-variables, + po-syntax-error, + str-format-used, + unnecessary-utf8-coding-comment, + xml-attribute-translatable, + xml-deprecated-qweb-directive, + xml-deprecated-tree-attribute, + attribute-string-redundant, + consider-merging-classes-inherited, + context-overridden, + except-pass, invalid-commit, manifest-maintainers-list, - missing-newline-extrafiles, missing-readme, missing-return, odoo-addons-relative-import, - old-api7-method-defined, - po-msgstr-variables, - po-syntax-error, renamed-field-parameter, resource-not-exist, - str-format-used, test-folder-imported, translation-contains-variable, translation-positional-used, - unnecessary-utf8-coding-comment, website-manifest-key-not-valid-uri, - xml-attribute-translatable, - xml-deprecated-qweb-directive, - xml-deprecated-tree-attribute, external-request-timeout [REPORTS] diff --git a/README.md b/README.md index a7b76e81c36f..79c6f7cbb052 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,6 @@ +[![Support the OCA](https://odoo-community.org/readme-banner-image)](https://odoo-community.org/get-involved?utm_source=repo-readme) +# web [![Runboat](https://img.shields.io/badge/runboat-Try%20me-875A7B.png)](https://runboat.odoo-community.org/builds?repo=OCA/web&target_branch=18.0) [![Pre-commit Status](https://github.com/OCA/web/actions/workflows/pre-commit.yml/badge.svg?branch=18.0)](https://github.com/OCA/web/actions/workflows/pre-commit.yml?query=branch%3A18.0) [![Build Status](https://github.com/OCA/web/actions/workflows/test.yml/badge.svg?branch=18.0)](https://github.com/OCA/web/actions/workflows/test.yml?query=branch%3A18.0) @@ -7,8 +9,6 @@ -# web - web @@ -23,7 +23,7 @@ addon | version | maintainers | summary --- | --- | --- | --- [web_calendar_slot_duration](web_calendar_slot_duration/) | 18.0.1.0.0 | Yajo | Customizable calendar slot durations [web_chatter_position](web_chatter_position/) | 18.0.1.0.1 | trisdoan | Add an option to change the chatter position -[web_company_color](web_company_color/) | 18.0.1.0.4 | | Web Company Color +[web_company_color](web_company_color/) | 18.0.1.0.6 | | Web Company Color [web_copy_confirm](web_copy_confirm/) | 18.0.1.0.0 | | Show confirmation dialogue before copying records [web_dark_mode](web_dark_mode/) | 18.0.1.0.0 | | Enabled Dark Mode for the Odoo Backend [web_datetime_picker_default_time](web_datetime_picker_default_time/) | 18.0.1.0.0 | grindtildeath | Allows to define a default time on datetime picker @@ -58,7 +58,7 @@ addon | version | maintainers | summary [web_sort_menu](web_sort_menu/) | 18.0.1.0.0 | | Sort Apps in DropDown/NavBar Menu alphabetically [web_systray_button_init_action](web_systray_button_init_action/) | 18.0.1.0.2 | | Add a button to go to the user init action. [web_theme_classic](web_theme_classic/) | 18.0.1.1.0 | legalsylvain | Contrasted style on fields to improve the UI. -[web_timeline](web_timeline/) | 18.0.1.0.1 | tarteo | Interactive visualization chart to show events in time +[web_timeline](web_timeline/) | 18.0.1.0.2 | tarteo | Interactive visualization chart to show events in time [web_touchscreen](web_touchscreen/) | 18.0.1.0.0 | yajo rafaelbn | UX improvements for touch screens [web_tree_column_keyboard_resize](web_tree_column_keyboard_resize/) | 18.0.1.0.0 | | Allow resizing tree view columns using keyboard shortcuts [web_tree_dynamic_colored_field](web_tree_dynamic_colored_field/) | 18.0.1.0.1 | | Allows you to dynamically color fields on tree views @@ -74,7 +74,7 @@ addon | version | maintainers | summary [web_widget_product_label_section_and_note_full_label](web_widget_product_label_section_and_note_full_label/) | 18.0.1.0.0 | | Display the full label in the product_label_section_and_note widget. [web_widget_product_label_section_and_note_name_visibility](web_widget_product_label_section_and_note_name_visibility/) | 18.0.1.0.1 | carlos-lopez-tecnativa | Alternate the visibility of the product and description. [web_widget_url_advanced](web_widget_url_advanced/) | 18.0.1.0.0 | | This module extends URL widget for displaying anchors with custom labels. -[web_widget_x2many_2d_matrix](web_widget_x2many_2d_matrix/) | 18.0.2.0.3 | JasminSForgeFlow DavidJForgeFlow hbrunn | Show list fields as a matrix +[web_widget_x2many_2d_matrix](web_widget_x2many_2d_matrix/) | 18.0.2.0.4 | JasminSForgeFlow DavidJForgeFlow hbrunn | Show list fields as a matrix [//]: # (end addons) diff --git a/web_company_color/README.rst b/web_company_color/README.rst index 13215077c780..dd301cf9259f 100644 --- a/web_company_color/README.rst +++ b/web_company_color/README.rst @@ -11,7 +11,7 @@ Web Company Color !! This file is generated by oca-gen-addon-readme !! !! changes will be overwritten. !! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - !! source digest: sha256:75f2396aade33370837fa8dc343dfb818e4b777b8115331fed547449727181f5 + !! source digest: sha256:8c4acd06346ec5b7687366b122ed8321c5312437d61d42ead690bd0308b2e82d !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! .. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png @@ -86,6 +86,10 @@ Contributors - Alexandre Díaz - Carlos Roca +- `PyTech `__: + + - Simone Rubino + Maintainers ----------- diff --git a/web_company_color/__manifest__.py b/web_company_color/__manifest__.py index be2582397a45..1c80998b4f3c 100644 --- a/web_company_color/__manifest__.py +++ b/web_company_color/__manifest__.py @@ -5,7 +5,7 @@ { "name": "Web Company Color", "category": "web", - "version": "18.0.1.0.4", + "version": "18.0.1.0.6", "author": "Alexandre Díaz, Odoo Community Association (OCA)", "website": "https://github.com/OCA/web", "depends": ["web", "base_sparse_field"], diff --git a/web_company_color/models/res_company.py b/web_company_color/models/res_company.py index f4c296b0fba6..02a355ac5eb9 100644 --- a/web_company_color/models/res_company.py +++ b/web_company_color/models/res_company.py @@ -5,6 +5,8 @@ from odoo import api, fields, models +from odoo.addons.base.models.assetsbundle import ScssStylesheetAsset + from ..utils import convert_to_image, image_to_rgb, n_rgb_to_hex URL_BASE = "/web_company_color/static/src/scss/" @@ -14,7 +16,8 @@ class ResCompany(models.Model): _inherit = "res.company" - SCSS_TEMPLATE = """ + def _get_scss_template(self): + return """ .o_main_navbar { background: %(color_navbar_bg)s !important; background-color: %(color_navbar_bg)s !important; @@ -231,7 +234,7 @@ def _scss_generate_content(self): # ir.attachment need files with content to work if not self.company_colors: return "// No Web Company Color SCSS Content\n" - return self.SCSS_TEMPLATE % self._scss_get_sanitized_values() + return self._get_scss_template() % self._scss_get_sanitized_values() def scss_get_url(self): self.ensure_one() @@ -240,8 +243,12 @@ def scss_get_url(self): def scss_create_or_update_attachment(self): IrAttachmentObj = self.env["ir.attachment"] for record in self: - datas = base64.b64encode(record._scss_generate_content().encode("utf-8")) custom_url = record.scss_get_url() + SCSS_asset = ScssStylesheetAsset( + "web_company_color.company_color_assets", url=custom_url + ) + compiled_CSS = SCSS_asset.compile(record._scss_generate_content()) + datas = base64.b64encode(compiled_CSS.encode("utf-8")) custom_attachment = IrAttachmentObj.sudo().search( [("url", "=", custom_url), ("company_id", "=", record.id)] ) diff --git a/web_company_color/readme/CONTRIBUTORS.md b/web_company_color/readme/CONTRIBUTORS.md index c66d22568de5..e074b858bf02 100644 --- a/web_company_color/readme/CONTRIBUTORS.md +++ b/web_company_color/readme/CONTRIBUTORS.md @@ -8,3 +8,5 @@ - Jairo Llopis - Alexandre Díaz - Carlos Roca +- [PyTech](https://www.pytech.it): + - Simone Rubino \<\> diff --git a/web_company_color/static/description/index.html b/web_company_color/static/description/index.html index 8545f0ec29b1..5b7a57114e3e 100644 --- a/web_company_color/static/description/index.html +++ b/web_company_color/static/description/index.html @@ -372,7 +372,7 @@

Web Company Color

!! This file is generated by oca-gen-addon-readme !! !! changes will be overwritten. !! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -!! source digest: sha256:75f2396aade33370837fa8dc343dfb818e4b777b8115331fed547449727181f5 +!! source digest: sha256:8c4acd06346ec5b7687366b122ed8321c5312437d61d42ead690bd0308b2e82d !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->

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

This module change navbar colors based in the company logo colors.

@@ -432,6 +432,10 @@

Contributors

  • Carlos Roca
  • +
  • PyTech: +
  • diff --git a/web_company_color/tests/test_res_company.py b/web_company_color/tests/test_res_company.py index 1c2fb665e975..0121e9eeefe2 100644 --- a/web_company_color/tests/test_res_company.py +++ b/web_company_color/tests/test_res_company.py @@ -1,5 +1,8 @@ # Copyright 2019 Alexandre Díaz # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +import base64 + from odoo.tests import common from ..models.res_company import URL_BASE @@ -75,3 +78,23 @@ def test_change_color(self): company_id.company_colors, "Invalid Navbar Background Color", ) + + def test_compiled_scss(self): + """The SCSS is compiled before being sent to the client.""" + # Arrange + company = self.env.company + color = "#d2e1dd" + desaturated_color = "#dadada" + company.color_navbar_bg = "desaturate(#d2e1dd, 30%)" + + # Act + company.scss_create_or_update_attachment() + + # Assert + attachment = self.env["ir.attachment"].search( + [("url", "=", company.scss_get_url())] + ) + css = base64.b64decode(attachment.datas).decode() + self.assertNotIn("desaturate", css) + self.assertNotIn(color, css) + self.assertIn(desaturated_color, css) diff --git a/web_timeline/README.rst b/web_timeline/README.rst index 7a5037984c63..458f557f340c 100644 --- a/web_timeline/README.rst +++ b/web_timeline/README.rst @@ -1,3 +1,7 @@ +.. image:: https://odoo-community.org/readme-banner-image + :target: https://odoo-community.org/get-involved?utm_source=readme + :alt: Odoo Community Association + ============ Web timeline ============ @@ -7,13 +11,13 @@ Web timeline !! This file is generated by oca-gen-addon-readme !! !! changes will be overwritten. !! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - !! source digest: sha256:f7afcee2d058a44cc7b44daf86593d10300c09feae36a156e0bdebaf3cb9836a + !! source digest: sha256:b1f365d7c54525677b42a9ea0ba1c61c2b9081842ee68246c77c710efacfd48f !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! .. |badge1| image:: https://img.shields.io/badge/maturity-Production%2FStable-green.png :target: https://odoo-community.org/page/development-status :alt: Production/Stable -.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png +.. |badge2| image:: https://img.shields.io/badge/license-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 @@ -45,88 +49,64 @@ Configuration You need to define a view with the tag as base element. These are the possible attributes for the tag: -+------------------+-----------+-------------------------------------+ -| Attribute | Required? | Description | -+==================+===========+=====================================+ -| date_start | **Yes** | Defines the name of the field of | -| | | type date that contains the start | -| | | of the event. | -+------------------+-----------+-------------------------------------+ -| date_stop | No | Defines the name of the field of | -| | | type date that contains the end of | -| | | the event. The date_stop can be | -| | | equal to the attribute date_start | -| | | to display events has 'point' on | -| | | the Timeline (instantaneous event). | -+------------------+-----------+-------------------------------------+ -| date_delay | No | Defines the name of the field of | -| | | type float/integer that contain the | -| | | duration in hours of the event, | -| | | default = 1. | -+------------------+-----------+-------------------------------------+ -| default_group_by | **Yes** | Defines the name of the field that | -| | | will be taken as default group by | -| | | when accessing the view or when no | -| | | other group by is selected. | -+------------------+-----------+-------------------------------------+ -| zoomKey | No | Specifies whether the Timeline is | -| | | only zoomed when an additional key | -| | | is down. Available values are '' | -| | | (does not apply), 'altKey', | -| | | 'ctrlKey', or 'metaKey'. Set this | -| | | option if you want to be able to | -| | | use the scroll to navigate | -| | | vertically on views with a lot of | -| | | events. | -+------------------+-----------+-------------------------------------+ -| mode | No | Specifies the initial visible | -| | | window. Available values are: 'day' | -| | | to display the current day, 'week', | -| | | 'month' and 'fit'. Default value is | -| | | 'fit' to adjust the visible window | -| | | such that it fits all items. | -+------------------+-----------+-------------------------------------+ -| margin | No | Specifies the margins around the | -| | | items. It should respect the JSON | -| | | format. For example | -| | | '{"item":{"horizontal":-10}}'. | -| | | Available values are: | -| | | '{"axis":}' (The minimal | -| | | margin in pixels between items and | -| | | the time axis) '{"item":}' | -| | | (The minimal margin in pixels | -| | | between items in both horizontal | -| | | and vertical direction), | -| | | '{"item":{"horizontal":}}' | -| | | (The minimal horizontal margin in | -| | | pixels between items), | -| | | '{"item":{"vertical":}}' | -| | | (The minimal vertical margin in | -| | | pixels between items), | -| | | '{"item":{"horizont | -| | | al":,"vertical":}}' | -| | | (Combination between horizontal and | -| | | vertical margins in pixels between | -| | | items). | -+------------------+-----------+-------------------------------------+ -| event_open_popup | No | When set to true, it allows to edit | -| | | the events in a popup. If not | -| | | (default value), the record is | -| | | edited changing to form view. | -+------------------+-----------+-------------------------------------+ -| stack | No | When set to false, items will not | -| | | be stacked on top of each other | -| | | such that they do overlap. | -+------------------+-----------+-------------------------------------+ -| colors | No | Allows to set certain specific | -| | | colors if the expressed condition | -| | | (JS syntax) is met. | -+------------------+-----------+-------------------------------------+ -| dependency_arrow | No | Set this attribute to a x2many | -| | | field to draw arrows between the | -| | | records referenced in the x2many | -| | | field. | -+------------------+-----------+-------------------------------------+ ++------------------+-----------+--------------------------------------------------------+ +| Attribute | Required? | Description | ++==================+===========+========================================================+ +| date_start | **Yes** | Defines the name of the field of type date that | +| | | contains the start of the event. | ++------------------+-----------+--------------------------------------------------------+ +| date_stop | No | Defines the name of the field of type date that | +| | | contains the end of the event. The date_stop can be | +| | | equal to the attribute date_start to display events | +| | | has 'point' on the Timeline (instantaneous event). | ++------------------+-----------+--------------------------------------------------------+ +| date_delay | No | Defines the name of the field of type float/integer | +| | | that contain the duration in hours of the event, | +| | | default = 1. | ++------------------+-----------+--------------------------------------------------------+ +| default_group_by | **Yes** | Defines the name of the field that will be taken as | +| | | default group by when accessing the view or when no | +| | | other group by is selected. | ++------------------+-----------+--------------------------------------------------------+ +| zoomKey | No | Specifies whether the Timeline is only zoomed when an | +| | | additional key is down. Available values are '' (does | +| | | not apply), 'altKey', 'ctrlKey', or 'metaKey'. Set | +| | | this option if you want to be able to use the scroll | +| | | to navigate vertically on views with a lot of events. | ++------------------+-----------+--------------------------------------------------------+ +| mode | No | Specifies the initial visible window. Available values | +| | | are: 'day' to display the current day, 'week', 'month' | +| | | and 'fit'. Default value is 'fit' to adjust the | +| | | visible window such that it fits all items. | ++------------------+-----------+--------------------------------------------------------+ +| margin | No | Specifies the margins around the items. It should | +| | | respect the JSON format. For example | +| | | '{"item":{"horizontal":-10}}'. Available values are: | +| | | '{"axis":}' (The minimal margin in pixels | +| | | between items and the time axis) '{"item":}' | +| | | (The minimal margin in pixels between items in both | +| | | horizontal and vertical direction), | +| | | '{"item":{"horizontal":}}' (The minimal | +| | | horizontal margin in pixels between items), | +| | | '{"item":{"vertical":}}' (The minimal vertical | +| | | margin in pixels between items), | +| | | '{"item":{"horizontal":,"vertical":}}' | +| | | (Combination between horizontal and vertical margins | +| | | in pixels between items). | ++------------------+-----------+--------------------------------------------------------+ +| event_open_popup | No | When set to true, it allows to edit the events in a | +| | | popup. If not (default value), the record is edited | +| | | changing to form view. | ++------------------+-----------+--------------------------------------------------------+ +| stack | No | When set to false, items will not be stacked on top of | +| | | each other such that they do overlap. | ++------------------+-----------+--------------------------------------------------------+ +| colors | No | Allows to set certain specific colors if the expressed | +| | | condition (JS syntax) is met. | ++------------------+-----------+--------------------------------------------------------+ +| dependency_arrow | No | Set this attribute to a x2many field to draw arrows | +| | | between the records referenced in the x2many field. | ++------------------+-----------+--------------------------------------------------------+ Optionally you can declare a custom template, which will be used to render the timeline items. You have to name the template diff --git a/web_timeline/__manifest__.py b/web_timeline/__manifest__.py index 3de3ff869872..c9a62bbe72e4 100644 --- a/web_timeline/__manifest__.py +++ b/web_timeline/__manifest__.py @@ -5,7 +5,7 @@ { "name": "Web timeline", "summary": "Interactive visualization chart to show events in time", - "version": "18.0.1.0.1", + "version": "18.0.1.0.2", "development_status": "Production/Stable", "author": "ACSONE SA/NV, " "Tecnativa, " diff --git a/web_timeline/static/description/index.html b/web_timeline/static/description/index.html index fae426f713a7..a715328b6adf 100644 --- a/web_timeline/static/description/index.html +++ b/web_timeline/static/description/index.html @@ -3,7 +3,7 @@ -Web timeline +README.rst -
    -

    Web timeline

    +
    + + +Odoo Community Association + +
    +

    Web timeline

    -

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

    +

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

    Define a new view displaying events in an interactive visualization chart.

    The widget is based on the external library @@ -390,14 +395,14 @@

    Web timeline

    -

    Configuration

    +

    Configuration

    You need to define a view with the tag <timeline> as base element. These are the possible attributes for the tag:

    ---+++ @@ -408,104 +413,80 @@

    Configuration

    - + - + - - - + - + - + - + - + - + - +
    Attribute
    date_start YesDefines the name of the field of -type date that contains the start -of the event.Defines the name of the field of type date that +contains the start of the event.
    date_stop NoDefines the name of the field of -type date that contains the end of -the event. The date_stop can be -equal to the attribute date_start -to display events has ‘point’ on -the Timeline (instantaneous event).Defines the name of the field of type date that +contains the end of the event. The date_stop can be +equal to the attribute date_start to display events +has ‘point’ on the Timeline (instantaneous event).
    date_delay NoDefines the name of the field of -type float/integer that contain the -duration in hours of the event, +Defines the name of the field of type float/integer +that contain the duration in hours of the event, default = 1.
    default_group_by YesDefines the name of the field that -will be taken as default group by -when accessing the view or when no +Defines the name of the field that will be taken as +default group by when accessing the view or when no other group by is selected.
    zoomKey NoSpecifies whether the Timeline is -only zoomed when an additional key -is down. Available values are ‘’ -(does not apply), ‘altKey’, -‘ctrlKey’, or ‘metaKey’. Set this -option if you want to be able to -use the scroll to navigate -vertically on views with a lot of -events.Specifies whether the Timeline is only zoomed when an +additional key is down. Available values are ‘’ (does +not apply), ‘altKey’, ‘ctrlKey’, or ‘metaKey’. Set +this option if you want to be able to use the scroll +to navigate vertically on views with a lot of events.
    mode NoSpecifies the initial visible -window. Available values are: ‘day’ -to display the current day, ‘week’, -‘month’ and ‘fit’. Default value is -‘fit’ to adjust the visible window -such that it fits all items.Specifies the initial visible window. Available values +are: ‘day’ to display the current day, ‘week’, ‘month’ +and ‘fit’. Default value is ‘fit’ to adjust the +visible window such that it fits all items.
    margin NoSpecifies the margins around the -items. It should respect the JSON -format. For example -‘{“item”:{“horizontal”:-10}}’. -Available values are: -‘{“axis”:<number>}’ (The minimal -margin in pixels between items and -the time axis) ‘{“item”:<number>}’ -(The minimal margin in pixels -between items in both horizontal -and vertical direction), -‘{“item”:{“horizontal”:<number>}}’ -(The minimal horizontal margin in -pixels between items), -‘{“item”:{“vertical”:<number>}}’ -(The minimal vertical margin in -pixels between items), -‘{“item”:{“horizont -al”:<number>,”vertical”:<number>}}’ -(Combination between horizontal and -vertical margins in pixels between -items).Specifies the margins around the items. It should +respect the JSON format. For example +‘{“item”:{“horizontal”:-10}}’. Available values are: +‘{“axis”:<number>}’ (The minimal margin in pixels +between items and the time axis) ‘{“item”:<number>}’ +(The minimal margin in pixels between items in both +horizontal and vertical direction), +‘{“item”:{“horizontal”:<number>}}’ (The minimal +horizontal margin in pixels between items), +‘{“item”:{“vertical”:<number>}}’ (The minimal vertical +margin in pixels between items), +‘{“item”:{“horizontal”:<number>,”vertical”:<number>}}’ +(Combination between horizontal and vertical margins +in pixels between items).
    event_open_popup NoWhen set to true, it allows to edit -the events in a popup. If not -(default value), the record is -edited changing to form view.When set to true, it allows to edit the events in a +popup. If not (default value), the record is edited +changing to form view.
    stack NoWhen set to false, items will not -be stacked on top of each other -such that they do overlap.When set to false, items will not be stacked on top of +each other such that they do overlap.
    colors NoAllows to set certain specific -colors if the expressed condition -(JS syntax) is met.Allows to set certain specific colors if the expressed +condition (JS syntax) is met.
    dependency_arrow NoSet this attribute to a x2many -field to draw arrows between the -records referenced in the x2many -field.Set this attribute to a x2many field to draw arrows +between the records referenced in the x2many field.
    @@ -585,7 +566,7 @@

    Configuration

    -

    Usage

    +

    Usage

    For accessing the timeline view, you have to click on the button with the clock icon in the view switcher. The first time you access to it, the timeline window is zoomed to fit all the current elements, the same @@ -613,7 +594,7 @@

    Usage

    create a new record with the dragged start and end date.

    -

    Known issues / Roadmap

    +

    Known issues / Roadmap

    • Implement a more efficient way of refreshing timeline after a record update;
    • @@ -632,7 +613,7 @@

      Known issues / Roadmap

    -

    Bug Tracker

    +

    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 @@ -640,9 +621,9 @@

    Bug Tracker

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

    -

    Credits

    +

    Credits

    -

    Authors

    +

    Authors

    • ACSONE SA/NV
    • Tecnativa
    • @@ -652,7 +633,7 @@

      Authors

    -

    Contributors

    +

    Contributors

    -

    Maintainers

    +

    Maintainers

    This module is maintained by the OCA.

    Odoo Community Association @@ -695,5 +676,6 @@

    Maintainers

    +
    diff --git a/web_timeline/static/src/views/timeline/timeline_canvas.esm.js b/web_timeline/static/src/views/timeline/timeline_canvas.esm.js index ed656a23d251..8c52e60e4509 100644 --- a/web_timeline/static/src/views/timeline/timeline_canvas.esm.js +++ b/web_timeline/static/src/views/timeline/timeline_canvas.esm.js @@ -10,20 +10,14 @@ export class TimelineCanvas { constructor(canvas_ref) { this.canvas_ref = canvas_ref; } + /** * Clears all drawings (svg elements) from the canvas. */ clear() { - if (this.canvas_ref) { - const tempElement = document.createElement("div"); - tempElement.innerHTML = this.canvas_ref; - Array.from(tempElement.children).forEach((child) => { - if (child.tagName.toLowerCase() !== "defs") { - child.remove(); - } - }); - this.canvas_ref = tempElement.innerHTML; - } + Array.from(this.canvas_ref.children) + .filter((el) => el.tagName.toLowerCase() !== "defs") + .forEach((el) => el.remove()); } /** @@ -158,9 +152,7 @@ export class TimelineCanvas { if (markerStart) { line.setAttribute("marker-start", `url(${markerStart})`); } - if (this.canvas_ref instanceof HTMLElement) { - this.canvas_ref.appendChild(line); - } + this.canvas_ref.appendChild(line); return line; } } diff --git a/web_timeline/static/src/views/timeline/timeline_renderer.esm.js b/web_timeline/static/src/views/timeline/timeline_renderer.esm.js index 4aaba72d0cfc..29a4790c0ebd 100644 --- a/web_timeline/static/src/views/timeline/timeline_renderer.esm.js +++ b/web_timeline/static/src/views/timeline/timeline_renderer.esm.js @@ -34,7 +34,10 @@ export class TimelineRenderer extends Component { this.fields = this.params.fields; this.timeline = false; this.initial_data_loaded = false; - this.canvas_ref = renderToString("TimelineView.Canvas", {}); + const canvas_str = renderToString("TimelineView.Canvas", {}); + const parser = new DOMParser(); + const svgDoc = parser.parseFromString(canvas_str, "image/svg+xml"); + this.canvas_ref = svgDoc.documentElement; onWillUpdateProps(async (props) => { this.on_data_loaded(props.model.data); }); @@ -220,8 +223,8 @@ export class TimelineRenderer extends Component { } this.$centerContainer = this.timeline.dom.centerContainer; this.canvas = new TimelineCanvas(this.canvas_ref); - if (this.$centerContainer.el) { - this.$centerContainer.el.appendChild(this.canvas_ref); + if (this.$centerContainer) { + this.$centerContainer.appendChild(this.canvas_ref); } this.timeline.on("changed", () => { this.draw_canvas(); diff --git a/web_widget_x2many_2d_matrix/README.rst b/web_widget_x2many_2d_matrix/README.rst index a90d4d6dde0c..5a65f3d8b241 100644 --- a/web_widget_x2many_2d_matrix/README.rst +++ b/web_widget_x2many_2d_matrix/README.rst @@ -11,7 +11,7 @@ !! This file is generated by oca-gen-addon-readme !! !! changes will be overwritten. !! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - !! source digest: sha256:5fc3c9f476ae769fdba13355a4c684becc3a2fec4ed42895f4cee2cb13b03965 + !! source digest: sha256:41c6c7108cfba49c27bb21ba60869217b580ba7a59e795d3a2eeb4ff004a5955 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! .. |badge1| image:: https://img.shields.io/badge/maturity-Production%2FStable-green.png diff --git a/web_widget_x2many_2d_matrix/__manifest__.py b/web_widget_x2many_2d_matrix/__manifest__.py index 14cf2368e4c8..c9ce9a8fa588 100644 --- a/web_widget_x2many_2d_matrix/__manifest__.py +++ b/web_widget_x2many_2d_matrix/__manifest__.py @@ -5,7 +5,7 @@ # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). { "name": "2D matrix for x2many fields", - "version": "18.0.2.0.3", + "version": "18.0.2.0.4", "maintainers": ["JasminSForgeFlow", "DavidJForgeFlow", "hbrunn"], "development_status": "Production/Stable", "author": ( diff --git a/web_widget_x2many_2d_matrix/static/description/index.html b/web_widget_x2many_2d_matrix/static/description/index.html index b95eff8e1479..bbdefccb47e7 100644 --- a/web_widget_x2many_2d_matrix/static/description/index.html +++ b/web_widget_x2many_2d_matrix/static/description/index.html @@ -372,7 +372,7 @@

    2D matrix for x2many fields

    !! This file is generated by oca-gen-addon-readme !! !! changes will be overwritten. !! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -!! source digest: sha256:5fc3c9f476ae769fdba13355a4c684becc3a2fec4ed42895f4cee2cb13b03965 +!! source digest: sha256:41c6c7108cfba49c27bb21ba60869217b580ba7a59e795d3a2eeb4ff004a5955 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->

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

    This module allows to show an x2many field with 3-tuples ($x_value, diff --git a/web_widget_x2many_2d_matrix/static/src/components/x2many_2d_matrix_renderer/x2many_2d_matrix_renderer.esm.js b/web_widget_x2many_2d_matrix/static/src/components/x2many_2d_matrix_renderer/x2many_2d_matrix_renderer.esm.js index 20016e5d3e8a..2ee6ece033b2 100644 --- a/web_widget_x2many_2d_matrix/static/src/components/x2many_2d_matrix_renderer/x2many_2d_matrix_renderer.esm.js +++ b/web_widget_x2many_2d_matrix/static/src/components/x2many_2d_matrix_renderer/x2many_2d_matrix_renderer.esm.js @@ -1,19 +1,16 @@ -import {Component, onWillUpdateProps} from "@odoo/owl"; import {evaluateBooleanExpr, evaluateExpr} from "@web/core/py_js/py"; +import {Component, onWillRender} from "@odoo/owl"; import {Domain} from "@web/core/domain"; import {Record} from "@web/model/relational_model/record"; import {getFieldContext} from "@web/model/relational_model/utils"; export class X2Many2DMatrixRenderer extends Component { setup() { - this.columns = this._getColumns(); - this.rows = this._getRows(); - this.matrix = this._getMatrix(); - - onWillUpdateProps((newProps) => { - this.columns = this._getColumns(newProps.list.records); - this.rows = this._getRows(newProps.list.records); - this.matrix = this._getMatrix(newProps.list.records); + onWillRender(() => { + const records = this.list.records; + this.columns = this._getColumns(records); + this.rows = this._getRows(records); + this.matrix = this._getMatrix(records); }); } diff --git a/web_widget_x2many_2d_matrix/static/tests/web_widget_x2many_2d_matrix.test.js b/web_widget_x2many_2d_matrix/static/tests/web_widget_x2many_2d_matrix.test.js index 942132b12d0c..c3f8575a7dda 100644 --- a/web_widget_x2many_2d_matrix/static/tests/web_widget_x2many_2d_matrix.test.js +++ b/web_widget_x2many_2d_matrix/static/tests/web_widget_x2many_2d_matrix.test.js @@ -1,5 +1,12 @@ -import {defineModels, fields, models, mountView} from "@web/../tests/web_test_helpers"; +import { + contains, + defineModels, + fields, + models, + mountView, +} from "@web/../tests/web_test_helpers"; import {describe, expect, test} from "@odoo/hoot"; +import {queryAll} from "@odoo/hoot-dom"; describe.current.tags("desktop"); @@ -63,12 +70,13 @@ class Line extends models.Model { } defineModels([Line, Main]); -test("matrix displaying float fields are rendered correctly", async () => { - await mountView({ - type: "form", - resModel: "main", - resId: 1, - arch: ` +describe("X2Many2DMatrixRenderer", () => { + test("matrix displaying float fields are rendered correctly", async () => { + await mountView({ + type: "form", + resModel: "main", + resId: 1, + arch: `

    @@ -78,17 +86,17 @@ test("matrix displaying float fields are rendered correctly", async () => {
    `, + }); + expect(".o_field_widget input").toHaveCount(4); + expect(".col-total").toHaveText("168.00"); }); - expect(".o_field_widget input").toHaveCount(4); - expect(".col-total").toHaveText("168.00"); -}); -test("matrix displaying float fields can be configured", async () => { - await mountView({ - type: "form", - resModel: "main", - resId: 1, - arch: ` + test("matrix displaying float fields can be configured", async () => { + await mountView({ + type: "form", + resModel: "main", + resId: 1, + arch: `
    @@ -98,16 +106,16 @@ test("matrix displaying float fields can be configured", async () => {
    `, + }); + expect(".o_field_widget input").toHaveValue("42.000"); }); - expect(".o_field_widget input").toHaveValue("42.000"); -}); -test("matrix displaying char fields are rendered correctly", async () => { - await mountView({ - type: "form", - resModel: "main", - resId: 1, - arch: ` + test("matrix displaying char fields are rendered correctly", async () => { + await mountView({ + type: "form", + resModel: "main", + resId: 1, + arch: `
    @@ -117,17 +125,17 @@ test("matrix displaying char fields are rendered correctly", async () => {
    `, + }); + expect(".o_field_widget input").toHaveCount(4); + expect(".col-total").toHaveCount(0); }); - expect(".o_field_widget input").toHaveCount(4); - expect(".col-total").toHaveCount(0); -}); -test("matrix displaying many2one fields are rendered correctly", async () => { - await mountView({ - type: "form", - resModel: "main", - resId: 1, - arch: ` + test("matrix displaying many2one fields are rendered correctly", async () => { + await mountView({ + type: "form", + resModel: "main", + resId: 1, + arch: `
    @@ -137,16 +145,16 @@ test("matrix displaying many2one fields are rendered correctly", async () => {
    `, + }); + expect(".o_field_many2one_selection").toHaveCount(4); + expect(".o_form_uri").toHaveCount(0); }); - expect(".o_field_many2one_selection").toHaveCount(4); - expect(".o_form_uri").toHaveCount(0); -}); -test("matrix displaying many2one fields can be configured", async () => { - await mountView({ - type: "form", - resModel: "main", - resId: 1, - arch: ` + test("matrix displaying many2one fields can be configured", async () => { + await mountView({ + type: "form", + resModel: "main", + resId: 1, + arch: `
    @@ -156,16 +164,16 @@ test("matrix displaying many2one fields can be configured", async () => {
    `, + }); + expect(".o_field_many2one_selection").toHaveCount(2); + expect(".o_form_uri").toHaveCount(2); }); - expect(".o_field_many2one_selection").toHaveCount(2); - expect(".o_form_uri").toHaveCount(2); -}); -test("matrix axis can be clickable", async () => { - await mountView({ - type: "form", - resModel: "main", - resId: 1, - arch: ` + test("matrix axis can be clickable", async () => { + await mountView({ + type: "form", + resModel: "main", + resId: 1, + arch: `
    @@ -174,6 +182,51 @@ test("matrix axis can be clickable", async () => {
    `, + }); + expect(".o_form_uri").toHaveCount(2); + }); + + test("matrix totals are updated correctly after several edits", async () => { + await mountView({ + type: "form", + resModel: "main", + resId: 1, + arch: ` +
    + + + + + + + +
    `, + }); + + expect(".col-total").toHaveText("168.00"); + + const inputs = queryAll(".o_field_widget input"); + // Initial state: [42, 42, 42, 42] -> Total 168 + + await contains(inputs[0]).edit("100"); + // State: [100, 42, 42, 42] -> Total 226 + expect(".col-total").toHaveText("226.00"); + + await contains(inputs[1]).edit("200"); + // State: [100, 200, 42, 42] -> Total 384 + expect(".col-total").toHaveText("384.00"); + + await contains(inputs[2]).edit("50"); + // State: [100, 200, 50, 42] -> Total 392 + expect(".col-total").toHaveText("392.00"); + + await contains(inputs[3]).edit("0"); + // State: [100, 200, 50, 0] -> Total 350 + expect(".col-total").toHaveText("350.00"); + + // Edit the first one again + await contains(inputs[0]).edit("10"); + // State: [10, 200, 50, 0] -> Total 260 + expect(".col-total").toHaveText("260.00"); }); - expect(".o_form_uri").toHaveCount(2); }); diff --git a/web_widget_x2many_2d_matrix/tests/test_web_widget_x2many_2d_matrix.py b/web_widget_x2many_2d_matrix/tests/test_web_widget_x2many_2d_matrix.py index 590738a1e63b..d5ae574625f7 100644 --- a/web_widget_x2many_2d_matrix/tests/test_web_widget_x2many_2d_matrix.py +++ b/web_widget_x2many_2d_matrix/tests/test_web_widget_x2many_2d_matrix.py @@ -5,7 +5,7 @@ class TestWebWidgetX2Many2DMatrix(HttpCase): def test_js(self): self.browser_js( - "/web/tests?headless&loglevel=2&preset=desktop&timeout=15000&id=b42fa5f8", + "/web/tests?headless&loglevel=2&preset=desktop&timeout=15000&filter=X2Many2DMatrixRenderer", "", "", login="admin",