Skip to content

[19.0][MIG] website_sale_product_attribute_value_filter_existing#1193

Open
augusto-weiss wants to merge 30 commits intoOCA:19.0from
adhoc-dev:19.0-mig-website_sale_product_attribute_value_filter_existing-awe
Open

[19.0][MIG] website_sale_product_attribute_value_filter_existing#1193
augusto-weiss wants to merge 30 commits intoOCA:19.0from
adhoc-dev:19.0-mig-website_sale_product_attribute_value_filter_existing-awe

Conversation

@augusto-weiss
Copy link
Copy Markdown

No description provided.

CarlosRoca13 and others added 29 commits April 6, 2026 12:49
… 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.
…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
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.
Copilot AI review requested due to automatic review settings April 6, 2026 17:16
@augusto-weiss augusto-weiss force-pushed the 19.0-mig-website_sale_product_attribute_value_filter_existing-awe branch from 24a5b8f to 5721fd4 Compare April 6, 2026 17:19
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment on lines +9 to +14
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[
Copy link

Copilot AI Apr 6, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copilot uses AI. Check for mistakes.
Comment on lines +20 to +22
"/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/"
Copy link

Copilot AI Apr 6, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 /).

Suggested change
"/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/"

Copilot uses AI. Check for mistakes.
Comment on lines +115 to +119
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"
Copy link

Copilot AI Apr 6, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Suggested change
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")

Copilot uses AI. Check for mistakes.
@@ -0,0 +1,18 @@
import {registry} from "@web/core/registry";
Copy link

Copilot AI Apr 6, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Import formatting is inconsistent with the repo's Prettier config (bracketSpacing: false). Use import {registry} ... (no spaces) to avoid formatting/lint churn.

Copilot uses AI. Check for mistakes.
Comment on lines +1 to +2
This module extends the functionality of website sale module to allow
hide product attributes values which exist but not used on any variants.
Copy link

Copilot AI Apr 6, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Suggested change
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.

Copilot uses AI. Check for mistakes.
Comment on lines +1 to +5
* 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.
Copy link

Copilot AI Apr 6, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Suggested change
* 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.

Copilot uses AI. Check for mistakes.
@augusto-weiss augusto-weiss force-pushed the 19.0-mig-website_sale_product_attribute_value_filter_existing-awe branch from 5721fd4 to 0a6e743 Compare April 6, 2026 17:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.