[19.0][MIG] website_sale_product_attribute_value_filter_existing#1193
[19.0][MIG] website_sale_product_attribute_value_filter_existing#1193augusto-weiss wants to merge 30 commits intoOCA:19.0from
Conversation
… to 15.0 [UPD] Update website_sale_product_attribute_value_filter_existing.pot
…nature match the function signature of shop with the original one from website_sale, to avoid potential issues with other modules overwriting the function and passing unexpected parameters
…to check the real functionality of the module TT45590
…ormance improvement - Switch to setUpClass for avoiding repeat the same setup for each test. - Include context keys for avoiding mail operations overhead.
…er extraction in mobile view
…ibute parent container If only the attribute container is hidden, the parent container still occupies a space that is visible in the attribute list. To avoid this, apply the condition to the parent container and hide it completely. TT50704
…ibute container TT51372
Updated by "Update PO files to match POT (msgmerge)" hook in Weblate. Translation: e-commerce-18.0/e-commerce-18.0-website_sale_product_attribute_value_filter_existing Translate-URL: https://translation.odoo-community.org/projects/e-commerce-18-0/e-commerce-18-0-website_sale_product_attribute_value_filter_existing/
…erformance using ID sets
The overhead of extending the entire "shop()" method is eliminated and
the logic is moved to "_get_additional_extra_shop_values()",
the hook provided by Odoo to add data to the context without duplicating
core code.
In addition, the filtering of unused values is optimized by avoiding
the intersection of recordsets in QWeb ("attr_values_used & v").
Instead, the IDs of used values are precomputed as a set
("attr_values_used_ids") and the templates check "v.id in attr_values_used_ids",
which drastically reduces the cost per iteration.
24a5b8f to
5721fd4
Compare
There was a problem hiding this comment.
Pull request overview
This PR migrates/adds the website_sale_product_attribute_value_filter_existing addon for Odoo 19.0, aiming to hide product attribute values in the shop filters when they are not used by the currently displayed products.
Changes:
- Add a controller hook to compute “used” attribute value ids for the current shop result set.
- Apply QWeb template conditions to hide unused attribute values across multiple filter display templates.
- Add frontend web tours + an HttpCase to validate the UI behavior, along with generated README/description/i18n scaffolding.
Reviewed changes
Copilot reviewed 19 out of 24 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
| website_sale_product_attribute_value_filter_existing/init.py | Initializes the addon Python package (imports controllers). |
| website_sale_product_attribute_value_filter_existing/manifest.py | Declares addon metadata and registers test assets (web tours). |
| website_sale_product_attribute_value_filter_existing/controllers/init.py | Exposes the controller module. |
| website_sale_product_attribute_value_filter_existing/controllers/main.py | Extends WebsiteSale to compute and inject attr_values_used_ids into shop rendering values. |
| website_sale_product_attribute_value_filter_existing/views/templates.xml | Adds t-if conditions to hide attribute values not in attr_values_used_ids. |
| website_sale_product_attribute_value_filter_existing/tests/init.py | Initializes the test package. |
| website_sale_product_attribute_value_filter_existing/tests/test_website_sale_product_attribute_value_filter_existing.py | Creates test products/attributes and runs UI tours to validate filter visibility. |
| website_sale_product_attribute_value_filter_existing/static/src/js/website_sale_product_attribute_value_filter_existing_tour.esm.js | Web tour asserting unused value (“Test yellow”) is hidden on /shop. |
| website_sale_product_attribute_value_filter_existing/static/src/js/website_sale_product_attribute_value_filter_existing_search_desk_tour.esm.js | Web tour asserting values not used in search result set are hidden. |
| website_sale_product_attribute_value_filter_existing/README.rst | Generated addon README. |
| website_sale_product_attribute_value_filter_existing/readme/DESCRIPTION.md | Short functional description for README generation. |
| website_sale_product_attribute_value_filter_existing/readme/CONFIGURATION.rst | User configuration instructions. |
| website_sale_product_attribute_value_filter_existing/readme/CONTRIBUTORS.md | Contributor listing. |
| website_sale_product_attribute_value_filter_existing/readme/CREDITS.md | Migration credit note. |
| website_sale_product_attribute_value_filter_existing/static/description/index.html | Generated long HTML description for Odoo Apps view. |
| website_sale_product_attribute_value_filter_existing/static/description/icon.png | Addon icon. |
| website_sale_product_attribute_value_filter_existing/i18n/website_sale_product_attribute_value_filter_existing.pot | Base translation template scaffold. |
| website_sale_product_attribute_value_filter_existing/i18n/tr.po | Turkish translation scaffold/header. |
| website_sale_product_attribute_value_filter_existing/i18n/pt_BR.po | Brazilian Portuguese translation scaffold/header. |
| website_sale_product_attribute_value_filter_existing/pyproject.toml | Packaging build-system metadata (whool). |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| def _get_additional_shop_values(self, values, **post): | ||
| res = super()._get_additional_shop_values(values, **post) | ||
| search_product = values.get("search_product") | ||
| attributes = values.get("attributes") | ||
| if search_product and attributes: | ||
| ProductTemplateAttributeLine = request.env[ |
There was a problem hiding this comment.
attr_values_used_ids is only added to res when both search_product and attributes are truthy. The inherited QWeb templates always reference attr_values_used_ids, so in cases like an empty result set (or any path where these keys are falsy) this can raise a QWeb rendering error due to an undefined variable. Set a default in res (e.g., False/empty) before the conditional, and then override it when you can compute used values.
| "/website_sale_product_attribute_value_filter_existing/static/src/js/" | ||
| "website_sale_product_attribute_value_filter_existing_tour.esm.js", | ||
| "/website_sale_product_attribute_value_filter_existing/static/src/js/" |
There was a problem hiding this comment.
The web.assets_tests entries use leading / absolute paths and point to static/src/js. In this repo, other addons register test tours via module-relative static/tests/**/* globs (no leading slash). Using absolute paths / a different folder risks the tours not being loaded by the test asset bundle. Consider moving tours under static/tests/tours/ and registering them with a module-relative glob (or at least drop the leading /).
| "/website_sale_product_attribute_value_filter_existing/static/src/js/" | |
| "website_sale_product_attribute_value_filter_existing_tour.esm.js", | |
| "/website_sale_product_attribute_value_filter_existing/static/src/js/" | |
| "website_sale_product_attribute_value_filter_existing/static/src/js/" | |
| "website_sale_product_attribute_value_filter_existing_tour.esm.js", | |
| "website_sale_product_attribute_value_filter_existing/static/src/js/" |
| cls.env["website"].with_context(website_id=website.id).viewref( | ||
| "website_sale.products_attributes" | ||
| ).active = True | ||
| cls.env["website"].with_context(website_id=website.id).viewref( | ||
| "website_sale.search" |
There was a problem hiding this comment.
These lines violate the repository's formatting conventions (ruff format / 88-char lines) and will likely fail linting due to overlong lines and inconsistent quoting. Please reformat/split the chained calls and use consistent double quotes.
| cls.env["website"].with_context(website_id=website.id).viewref( | |
| "website_sale.products_attributes" | |
| ).active = True | |
| cls.env["website"].with_context(website_id=website.id).viewref( | |
| "website_sale.search" | |
| ( | |
| cls.env["website"] | |
| .with_context(website_id=website.id) | |
| .viewref("website_sale.products_attributes") | |
| ).active = True | |
| ( | |
| cls.env["website"] | |
| .with_context(website_id=website.id) | |
| .viewref("website_sale.search") |
| @@ -0,0 +1,18 @@ | |||
| import {registry} from "@web/core/registry"; | |||
There was a problem hiding this comment.
Import formatting is inconsistent with the repo's Prettier config (bracketSpacing: false). Use import {registry} ... (no spaces) to avoid formatting/lint churn.
| This module extends the functionality of website sale module to allow | ||
| hide product attributes values which exist but not used on any variants. |
There was a problem hiding this comment.
Grammar in the module description is off (e.g., "to allow hide" / "values which exist but not used"). Please rephrase to something like "to hide product attribute values that exist but are not used on any variants" for clarity.
| This module extends the functionality of website sale module to allow | |
| hide product attributes values which exist but not used on any variants. | |
| This module extends the functionality of the website sale module to hide | |
| product attribute values that exist but are not used on any variants. |
| * Go to Website Shop | ||
| * Active product attributes filter on theme panel option of shopping page | ||
| - Click edit button on shopping page (or directly go url: http://{your-domain}/@/shop) | ||
| - On tab `Customize`, enable attributes filter to show attribute values left of the layout. | ||
| * System only display the attribute values if used. |
There was a problem hiding this comment.
This configuration text has multiple grammar issues (e.g., "Active" vs "Activate", "System only display"). Please correct wording to be clear and professional for end users.
| * Go to Website Shop | |
| * Active product attributes filter on theme panel option of shopping page | |
| - Click edit button on shopping page (or directly go url: http://{your-domain}/@/shop) | |
| - On tab `Customize`, enable attributes filter to show attribute values left of the layout. | |
| * System only display the attribute values if used. | |
| * Go to the Website Shop. | |
| * Activate the product attribute filter in the theme panel options on the shopping page. | |
| - Click the Edit button on the shopping page (or go directly to the URL: http://{your-domain}/@/shop). | |
| - On the `Customize` tab, enable the attribute filter to show attribute values on the left side of the layout. | |
| * The system displays only the attribute values that are in use. |
5721fd4 to
0a6e743
Compare
No description provided.