Skip to content
Open
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
110 changes: 110 additions & 0 deletions website_sale_category_show_empty/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
.. image:: https://odoo-community.org/readme-banner-image
:target: https://odoo-community.org/get-involved?utm_source=readme
:alt: Odoo Community Association

================================
Website Sale Category Show Empty
================================

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

.. |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_category_show_empty
: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_category_show_empty
: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|

Odoo hides eCommerce category pages that hold no published product from
public and portal visitors. The record rule
``website_sale.empty_public_categories_rule`` restricts them to
categories where ``has_published_products`` is true, and because the
``/shop/category`` route turns the resulting access error into a 404,
visitors get a "page not found" instead of the category page.

That is the wanted behaviour for a catalogue that mirrors stock, but not
for pages that carry editorial content of their own -- a manufacturer or
brand page, for instance, which a shop may want to keep reachable even
while nothing of that brand is published.

This module adds a *Show When Empty* flag on the category. Flagged
categories stay readable for public and portal visitors whatever their
product count.

**Table of contents**

.. contents::
:local:

Usage
=====

1. Go to *Website > eCommerce > Products > eCommerce Categories*.
2. Open a category and tick *Show When Empty*.

The category page is now reachable for visitors even with no published
product, and renders as an empty category.

Note that the flag governs access to the page only. Shop sidebars and
mega menus filter on ``has_published_products`` directly rather than
through the record rule, so a flagged empty category is reachable by its
URL but is still left out of those navigation blocks.

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_category_show_empty%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
-------

* ForgeFlow

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

- `ForgeFlow <https://www.forgeflow.com>`__:

- Marc Gimeno

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_category_show_empty>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
1 change: 1 addition & 0 deletions website_sale_category_show_empty/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import models
19 changes: 19 additions & 0 deletions website_sale_category_show_empty/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Copyright 2026 ForgeFlow S.L. (https://www.forgeflow.com)
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

{
"name": "Website Sale Category Show Empty",
"summary": "Let public and portal visitors open eCommerce category pages"
" that have no published products",
"version": "19.0.1.0.0",
"author": "ForgeFlow, Odoo Community Association (OCA)",
"website": "https://github.com/OCA/e-commerce",
"license": "AGPL-3",
"category": "Website",
"depends": ["website_sale"],
"data": [
"security/product_public_category_security.xml",
"views/product_public_category_views.xml",
],
"installable": True,
}
1 change: 1 addition & 0 deletions website_sale_category_show_empty/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import product_public_category
14 changes: 14 additions & 0 deletions website_sale_category_show_empty/models/product_public_category.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Copyright 2026 ForgeFlow S.L. (https://www.forgeflow.com)
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

from odoo import fields, models


class ProductPublicCategory(models.Model):
_inherit = "product.public.category"

show_when_empty = fields.Boolean(
help="Let public and portal visitors open this category's page even "
"when neither the category nor its children hold a published "
"product. Without this, the page answers 404.",
)
3 changes: 3 additions & 0 deletions website_sale_category_show_empty/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[build-system]
requires = ["whool"]
build-backend = "whool.buildapi"
2 changes: 2 additions & 0 deletions website_sale_category_show_empty/readme/CONTRIBUTORS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
- [ForgeFlow](https://www.forgeflow.com):
- Marc Gimeno
15 changes: 15 additions & 0 deletions website_sale_category_show_empty/readme/DESCRIPTION.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
Odoo hides eCommerce category pages that hold no published product from
public and portal visitors. The record rule
`website_sale.empty_public_categories_rule` restricts them to categories
where `has_published_products` is true, and because the `/shop/category`
route turns the resulting access error into a 404, visitors get a "page
not found" instead of the category page.

That is the wanted behaviour for a catalogue that mirrors stock, but not
for pages that carry editorial content of their own -- a manufacturer or
brand page, for instance, which a shop may want to keep reachable even
while nothing of that brand is published.

This module adds a *Show When Empty* flag on the category. Flagged
categories stay readable for public and portal visitors whatever their
product count.
10 changes: 10 additions & 0 deletions website_sale_category_show_empty/readme/USAGE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
1. Go to *Website \> eCommerce \> Products \> eCommerce Categories*.
2. Open a category and tick *Show When Empty*.

The category page is now reachable for visitors even with no published
product, and renders as an empty category.

Note that the flag governs access to the page only. Shop sidebars and
mega menus filter on `has_published_products` directly rather than
through the record rule, so a flagged empty category is reachable by its
URL but is still left out of those navigation blocks.
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?xml version="1.0" encoding="utf-8" ?>
<odoo>
<!--
`website_sale.empty_public_categories_rule` restricts public and portal
visitors to categories holding a published product. Record rules bound
to groups are OR-ed together (see `ir.rule._compute_domain`), so adding
a second rule on the same groups widens the first one instead of
fighting it, and leaves the core record untouched on uninstall.
-->
<record id="show_empty_public_categories_rule" model="ir.rule">
<field
name="name"
>Show flagged empty eCommerce categories to public/portal users</field>
<field name="model_id" ref="website_sale.model_product_public_category" />
<field name="domain_force">[('show_when_empty', '=', True)]</field>
<field
name="groups"
eval="[
Command.link(ref('base.group_public')),
Command.link(ref('base.group_portal')),
]"
/>
<field name="perm_read" eval="True" />
<field name="perm_write" eval="False" />
<field name="perm_create" eval="False" />
<field name="perm_unlink" eval="False" />
</record>
</odoo>
Loading
Loading