Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
103 changes: 103 additions & 0 deletions website_sale_comparison_specification_exclusion/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
.. image:: https://odoo-community.org/readme-banner-image
:target: https://odoo-community.org/get-involved?utm_source=readme
:alt: Odoo Community Association

===============================================
Website Sale Comparison Specification Exclusion
===============================================

..
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:ce56b74965377f0c4f77763a31e9f81161d228254fabdf32c983fc96c5c6c84f
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
:target: https://odoo-community.org/page/development-status
:alt: Beta
.. |badge2| image:: https://img.shields.io/badge/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%2Fe--commerce-lightgray.png?logo=github
:target: https://github.com/OCA/e-commerce/tree/19.0/website_sale_comparison_specification_exclusion
:alt: OCA/e-commerce
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/e-commerce-19-0/e-commerce-19-0-website_sale_comparison_specification_exclusion
:alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png
:target: https://runboat.odoo-community.org/builds?repo=OCA/e-commerce&target_branch=19.0
:alt: Try me on Runboat

|badge1| |badge2| |badge3| |badge4| |badge5|

On the eCommerce product page, the "Specifications" table added by
``website_sale_comparison`` lists every attribute of the product,
including non-variant-defining ("informative") attributes whose values
can be restricted to specific variant combinations via the attribute
value's "Exclude for" configuration.

Without this module, that table always lists every configured value of
such an attribute, and never updates when the customer changes the
selected variant. This module makes it show only the value(s) actually
compatible with the combination currently selected on the page, and
refreshes that table when the customer changes variant.

**Table of contents**

.. contents::
:local:

Usage
=====

1. Go to *Website > Products > Attributes*.
2. On a non-variant-defining attribute's value, configure "Exclude for"
to list the variant-defining value(s) it is incompatible with.
3. On the eCommerce product page, the "Specifications" table will only
show the value(s) of that attribute compatible with the currently
selected variant, and will update automatically when the customer
changes it.

Bug Tracker
===========

Bugs are tracked on `GitHub Issues <https://github.com/OCA/e-commerce/issues>`_.
In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us to smash it by providing a detailed and welcomed
`feedback <https://github.com/OCA/e-commerce/issues/new?body=module:%20website_sale_comparison_specification_exclusion%0Aversion:%2019.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.

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

Credits
=======

Authors
-------

* Camptocamp

Contributors
------------

- `Camptocamp <https://www.camptocamp.com/>`__:

- Ricardoalso <ricardo.almeidasoares@camptocamp.com>

Maintainers
-----------

This module is maintained by the OCA.

.. image:: https://odoo-community.org/logo.png
:alt: Odoo Community Association
:target: https://odoo-community.org

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

This module is part of the `OCA/e-commerce <https://github.com/OCA/e-commerce/tree/19.0/website_sale_comparison_specification_exclusion>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
2 changes: 2 additions & 0 deletions website_sale_comparison_specification_exclusion/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
from . import controllers
from . import models
24 changes: 24 additions & 0 deletions website_sale_comparison_specification_exclusion/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Copyright 2026 Camptocamp SA (https://www.camptocamp.com).
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
{
"name": "Website Sale Comparison Specification Exclusion",
"version": "19.0.1.0.0",
"development_status": "Beta",
"category": "Website",
"website": "https://github.com/OCA/e-commerce",
"author": "Camptocamp, Odoo Community Association (OCA)",
"license": "AGPL-3",
"application": False,
"installable": True,
"depends": [
"website_sale_comparison",
],
"data": [
"views/templates.xml",
],
"assets": {
"web.assets_frontend": [
"website_sale_comparison_specification_exclusion/static/src/interactions/**/*",
],
},
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import variant
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# Copyright 2026 Camptocamp SA (https://www.camptocamp.com).
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

from odoo.http import request, route

from odoo.addons.website_sale.controllers.variant import WebsiteSaleVariantController


class WebsiteSaleSpecificationExclusionVariantController(WebsiteSaleVariantController):
@route(
"/website_sale/get_combination_info",
type="jsonrpc",
auth="public",
methods=["POST"],
website=True,
readonly=True,
)
def get_combination_info_website(
self,
product_template_id,
product_id,
combination,
add_qty,
uom_id=None,
**kwargs,
):
combination_info = super().get_combination_info_website(
product_template_id=product_template_id,
product_id=product_id,
combination=combination,
add_qty=add_qty,
uom_id=uom_id,
**kwargs,
)
product_template = request.env["product.template"].browse(
int(product_template_id)
)
specs_table_html = product_template._get_specs_table_html(
request.env["product.template.attribute.value"].browse(combination)
)
if specs_table_html is not None:
combination_info["specs_table_html"] = specs_table_html
return combination_info
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
from . import product_template
from . import product_template_attribute_line
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# Copyright 2026 Camptocamp SA (https://www.camptocamp.com).
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

from odoo import models


class ProductTemplate(models.Model):
_inherit = "product.template"

def _get_display_attribute_exclusions(self):
self.ensure_one()
return self._complete_inverse_exclusions(self._get_own_attribute_exclusions())

def _get_specs_table_html(self, combination):
"""Render the specs table content for the given `combination`
(recordset of `product.template.attribute.value`), so it can be
refreshed client-side when the customer changes variant.

Called only from the `/website_sale/get_combination_info` controller
"""
self.ensure_one()
has_filterable_line = any(
ptal.attribute_id.create_variant == "no_variant" and len(ptal.value_ids) > 1
for ptal in self.valid_product_template_attribute_line_ids
)
if not has_filterable_line:
return None
attribute_lines = self.valid_product_template_attribute_line_ids
attrib_categories = (
attribute_lines._prepare_categories_for_display_in_specs_table()
)
if not attrib_categories:
return None
exclusions = self._get_display_attribute_exclusions()
return self.env["ir.qweb"]._render(
"website_sale_comparison_specification_exclusion"
".product_specifications_content",
{
"attrib_categories": attrib_categories,
"combination": combination,
"attribute_exclusions": exclusions,
},
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Copyright 2026 Camptocamp SA (https://www.camptocamp.com).
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

from odoo import models


class ProductTemplateAttributeLine(models.Model):
_inherit = "product.template.attribute.line"

def _get_display_value_ids(self, combination, exclusions=None):
self.ensure_one()
if not combination or self.attribute_id.create_variant != "no_variant":
return self.value_ids
if exclusions is None:
exclusions = self.product_tmpl_id._get_display_attribute_exclusions()
other_ids = set(combination.ids) - set(self.product_template_value_ids.ids)
displayed_value_ids = set()
for ptav in self.product_template_value_ids:
conflicts = any(
other_id in exclusions.get(ptav.id, []) for other_id in other_ids
)
if not conflicts:
displayed_value_ids.add(ptav.product_attribute_value_id.id)
return self.env["product.attribute.value"].browse(displayed_value_ids).exists()
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[build-system]
requires = ["whool"]
build-backend = "whool.buildapi"
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
- [Camptocamp](https://www.camptocamp.com/):
- Ricardoalso \<<ricardo.almeidasoares@camptocamp.com>\>
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
On the eCommerce product page, the "Specifications" table added by
`website_sale_comparison` lists every attribute of the product,
including non-variant-defining ("informative") attributes whose values
can be restricted to specific variant combinations via the attribute
value's "Exclude for" configuration.

Without this module, that table always lists every configured value of
such an attribute, and never updates when the customer changes the
selected variant. This module makes it show only the value(s) actually
compatible with the combination currently selected on the page, and
refreshes that table when the customer changes variant.
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
1. Go to *Website \> Products \> Attributes*.
2. On a non-variant-defining attribute's value, configure "Exclude for"
to list the variant-defining value(s) it is incompatible with.
3. On the eCommerce product page, the "Specifications" table will only
show the value(s) of that attribute compatible with the currently
selected variant, and will update automatically when the customer
changes it.
Loading
Loading