Skip to content
Draft
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
6 changes: 6 additions & 0 deletions test-requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
odoo-addon-attribute_set @ git+https://github.com/OCA/odoo-pim.git@refs/pull/226/head#subdirectory=attribute_set
odoo-addon-attribute_set_jsonb @ git+https://github.com/OCA/odoo-pim.git@refs/pull/236/head#subdirectory=attribute_set_jsonb
odoo-addon-base_sparse_field_jsonb @ git+https://github.com/OCA/server-tools@refs/pull/3480/head#subdirectory=base_sparse_field_jsonb
odoo-addon-attribute_set_jsonb_index @ git+https://github.com/OCA/odoo-pim@refs/pull/237/head#subdirectory=attribute_set_jsonb_index
odoo-addon-website_attribute_set @ git+https://github.com/OCA/odoo-pim@refs/pull/229/head#subdirectory=website_attribute_set
odoo-addon-product_attribute_set @ git+https://github.com/OCA/odoo-pim.git@refs/pull/232/head#subdirectory=product_attribute_set
246 changes: 246 additions & 0 deletions website_attribute_set_jsonb/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,246 @@
.. image:: https://odoo-community.org/readme-banner-image
:target: https://odoo-community.org/get-involved?utm_source=readme
:alt: Odoo Community Association

===========================
Website Attribute Set JSONB
===========================

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

.. |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%2Fodoo--pim-lightgray.png?logo=github
:target: https://github.com/OCA/odoo-pim/tree/19.0/website_attribute_set_jsonb
:alt: OCA/odoo-pim
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/odoo-pim-19-0/odoo-pim-19-0-website_attribute_set_jsonb
: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/odoo-pim&target_branch=19.0
:alt: Try me on Runboat

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

This module integrates OCA's ``attribute_set`` JSONB serialized
attributes with Odoo's website shop filtering system.

Features
--------

- **Website Visibility Configuration**: Mark JSONB attributes as visible
in website shop filters
- **Multiple Filter Types**: Support for checkbox, dropdown, and range
slider filters
- **Facet Counting**: Displays count of products matching each filter
value
- **Range Queries**: Efficient range filtering for numeric/date
attributes using B-tree indexes
- **URL Parameter Preservation**: Filter selections persist across
pagination and sorting
- **Active Filter Tags**: Visual display of currently applied filters
with easy removal

Use Cases
---------

- Heavy equipment dealers: Filter machines by capacity, year, brand
- E-commerce sites: Filter products by custom dynamic attributes
- B2B portals: Filter by technical specifications stored in JSONB

Performance
-----------

This module uses PostgreSQL JSONB operators directly for efficient
filtering:

- GIN indexes for equality/containment queries
- B-tree expression indexes for range queries (>, <, BETWEEN)
- Direct SQL for facet counting to avoid ORM overhead

**Table of contents**

.. contents::
:local:

Configuration
=============

Prerequisites
-------------

1. Install ``attribute_set`` from OCA/odoo-pim
2. Install ``base_sparse_field_jsonb`` for JSONB support
3. Create serialized attributes on ``product.template``

Index Configuration
-------------------

For optimal performance, configure indexes based on filter type:

Equality Filters (checkbox, dropdown)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Set **Index Type** to **GIN (equality/containment)** on the attribute.

Range Filters
~~~~~~~~~~~~~

Set **Index Type** to **B-tree (range queries)** on the attribute.

Template Customization
----------------------

The filter template can be customized by inheriting:

- ``website_attribute_set_jsonb.jsonb_attributes_filter``
- ``website_attribute_set_jsonb.products_jsonb_attributes``

Example:

.. code:: xml

<template id="custom_jsonb_filter" inherit_id="website_attribute_set_jsonb.jsonb_attributes_filter">
<xpath expr="//div[hasclass('accordion-body')]" position="attributes">
<attribute name="class" add="custom-filter-body"/>
</xpath>
</template>

Styling
-------

Override SCSS variables or add custom styles:

.. code:: scss

.o_jsonb_attribute_filter {
.accordion-body {
max-height: 400px; // Increase max height
}
}

Usage
=====

Configuration
-------------

1. Navigate to **Settings > Technical > Attributes > Attributes**
2. Select a serialized attribute you want to show in website filters
3. Enable **Show in Website Filters**
4. Choose the **Filter Display Type**:

- **Checkbox**: Multiple selection with checkboxes
- **Dropdown**: Single selection dropdown
- **Range Slider**: For numeric/date attributes with min/max input

5. Set the **Website Filter Sequence** to control display order

Filter Types
------------

Checkbox Filter
~~~~~~~~~~~~~~~

Best for attributes with multiple discrete values where users may want
to select multiple options:

- Brand: Caterpillar, Komatsu, Volvo
- Color: Red, Blue, Green

Dropdown Filter
~~~~~~~~~~~~~~~

Best for single-selection attributes or when there are many values:

- Country of Origin
- Condition (New, Used, Refurbished)

Range Filter
~~~~~~~~~~~~

Best for numeric attributes where users want to filter by range:

- Capacity (kg): 1000 - 5000
- Manufacturing Year: 2020 - 2024
- Operating Weight: 10 - 50 tons

**Note**: Range filters work best when the attribute has a B-tree index
configured in ``base_sparse_field_jsonb``.

URL Parameters
--------------

Filter selections are passed as URL parameters:

- Equality: ``?jsonb_x_brand=caterpillar,komatsu``
- Range: ``?jsonb_range_x_capacity=1000-5000``

This allows for:

- Bookmarkable filtered URLs
- SEO-friendly filter pages
- Integration with external marketing tools

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

Bugs are tracked on `GitHub Issues <https://github.com/OCA/odoo-pim/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/odoo-pim/issues/new?body=module:%20website_attribute_set_jsonb%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
-------

* OBS Solutions B.V.

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

- OBS Solutions B.V. https://www.obs-solutions.com

Other credits
-------------

Development
~~~~~~~~~~~

This module was developed by OBS Solutions B.V.

Sponsors
~~~~~~~~

- International Heavy Equipment Dealer (Netherlands)

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/odoo-pim <https://github.com/OCA/odoo-pim/tree/19.0/website_attribute_set_jsonb>`_ 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_attribute_set_jsonb/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
from . import controllers
from . import models
26 changes: 26 additions & 0 deletions website_attribute_set_jsonb/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
"name": "Website Attribute Set JSONB",
"version": "19.0.1.0.1",
"category": "Website/Website",
"summary": "Website shop filtering for JSONB serialized attributes",
"author": "OBS Solutions B.V., Odoo Community Association (OCA)",
"website": "https://github.com/OCA/odoo-pim",
"license": "AGPL-3",
"depends": [
"website_sale",
"website_attribute_set",
"attribute_set_jsonb",
"attribute_set_jsonb_index",
],
"data": [
"views/attribute_attribute_views.xml",
"views/templates.xml",
],
"assets": {
"web.assets_frontend": [
"website_attribute_set_jsonb/static/src/scss/website_attribute_set.scss",
],
},
"installable": True,
"auto_install": False,
}
1 change: 1 addition & 0 deletions website_attribute_set_jsonb/controllers/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import main
Loading
Loading