Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
611887e
[ADD] website_snippet_product_category
Tardo May 25, 2020
11bf8da
[FIX] website_snippet_product_category: Title s/wesbite/website
pedrobaeza Sep 11, 2020
fb46b71
[FIX] website_snippet_product_category: Proper smart-button
pedrobaeza Sep 11, 2020
9a25c75
Added translation using Weblate (Spanish)
claudiagn Nov 3, 2020
bafeebd
Added translation using Weblate (French)
ypapouin Nov 23, 2020
155a821
Added translation using Weblate (Dutch)
bosd Dec 15, 2020
3b7c176
Added translation using Weblate (Catalan)
claudiagn Jan 20, 2021
b301fe0
[MIG] website_snippet_product_category: Migration to v13.0
CarlosRoca13 Apr 9, 2021
43d33da
[IMP] website_snippet_product_category: Change website published fiel…
sergio-teruel Dec 17, 2021
53becce
[FIX] website_snippet_product_category: Revert field name swap in web…
pedrobaeza Dec 24, 2021
c334045
[IMP] website_snippet_product_category: Reduced the icon size of the …
Tardo Dec 24, 2021
7835d13
website_snippet_product_category 13.0.2.1.0
OCA-git-bot Dec 27, 2021
3e8a444
Translated using Weblate (Catalan)
Noel000 Mar 2, 2022
5a5d6f4
Translated using Weblate (Spanish)
macagua May 24, 2022
11f1c0c
[MIG] website_snippet_product_category: Migration to version 15.0
pilarvargas-tecnativa Feb 9, 2023
fd64135
[MIG] website_snippet_product_category: Migration to 16.0
pilarvargas-tecnativa Aug 8, 2023
7b1b989
Added translation using Weblate (Italian)
mymage May 8, 2024
431427c
[IMP] website_snippet_product_category: pre-commit auto fixes
pilarvargas-tecnativa Feb 3, 2025
037f131
[MIG] website_snippet_product_category: Migration to version 17.0
pilarvargas-tecnativa Feb 3, 2025
12abd8b
[MIG] website_snippet_product_category: Migration to version 18.0
pilarvargas-tecnativa Feb 11, 2025
33ec804
Translated using Weblate (Italian)
mymage Feb 18, 2025
3368d87
Added translation using Weblate (Portuguese (Brazil))
marcelsavegnago Jun 29, 2025
8284b28
[FIX] website_sale_*: sort-imports
Kimkhoi3010 Jan 19, 2026
9a0b8eb
Translated using Weblate (French)
weblate Feb 25, 2026
78b2ef3
Translated using Weblate (Dutch)
weblate Feb 25, 2026
8f23cc1
Translated using Weblate (Catalan)
weblate Feb 25, 2026
9d620e4
Translated using Weblate (Portuguese (Brazil))
weblate Feb 25, 2026
d258363
Translated using Weblate (Spanish)
weblate Feb 25, 2026
aa6a48c
Translated using Weblate (Italian)
weblate Feb 25, 2026
936d8c1
Translated using Weblate (Spanish)
Ed-Spain Apr 22, 2026
c1bb2e0
[IMP] website_snippet_product_category: add website-specific snippet …
pilarvargas-tecnativa Mar 27, 2026
adfb1aa
Translated using Weblate (Catalan)
eugenichafer May 23, 2026
84910eb
Translated using Weblate (Italian)
mymage May 25, 2026
e9eb61f
Translated using Weblate (Spanish)
Ed-Spain Jun 27, 2026
bb02093
[MIG] website_snippet_product_category: Migration to 19.0
cristina-hidalgo-tecnativa Aug 17, 2026
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
161 changes: 161 additions & 0 deletions website_snippet_product_category/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,161 @@
.. image:: https://odoo-community.org/readme-banner-image
:target: https://odoo-community.org/get-involved?utm_source=readme
:alt: Odoo Community Association

================================
Website Snippet Product Category
================================

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

.. |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-LGPL--3-blue.png
:target: http://www.gnu.org/licenses/lgpl-3.0-standalone.html
:alt: License: LGPL-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_snippet_product_category
: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_snippet_product_category
: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|

Adds a new snippet to show e-commerce categories.

The snippet only displays categories explicitly enabled for it, and can
optionally restrict them to selected websites.

**Table of contents**

.. contents::
:local:

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

You can select what categories can be shown by the snippet and an image
for the category:

1. Go to website > eCommerce > eCommerce Categories
2. Create or Edit one
3. You can see a new options "Published in product category snippet"
4. You can also set "Websites for category snippet" to restrict where
the category is shown in the snippet. Leave it empty to show it on
all websites.

Usage
=====

1. Go to website (frontend)
2. Press 'Edit' button
3. Drag the 'Product Category' snippet to the place of the website that
you want
4. Save changes

Theming
-------

CSS Classes:

- ``.categ_container`` > The container per master category
- ``.categ_scroll_wrapper`` > The scrollable container wrapper
- ``.categ_scroll`` > The scrollable container
- ``.categ_tree_level`` > The category row (image + text)
- ``.main_tree_level`` > The first category row level displayed
- ``.categ_link`` > The link of the category row
- ``.categ_img`` > The container of the icon of the category row

You can use 'data-tree-level' attribute to select the category row of a
selected level (1-4 by design).

Also you can replace the entire template by setting the
``data-template`` attribute directly on the ``.js_product_category``
element, e.g. by inheriting the view where the snippet is placed:

.. code:: xml

<xpath expr="//div[hasclass('js_product_category')]" position="attributes">
<attribute name="data-template">my_module.my_custom_template</attribute>
</xpath>

You only need know that the name of the variable that have all the
categories is called ``object``.

Known issues / Roadmap
======================

- The snippet shows a maximum of 4 levels by design.
- Add a option to configure the initial level
- Add a option to select how many levels can be represented
- Handle large amounts of categories

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

* Tecnativa

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

- `Tecnativa <https://www.tecnativa.com>`__:

- Alexandre D. Díaz
- Pedro M. Baeza
- Carlos Roca
- Sergio Teruel
- Pilar Vargas

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

static/img/boxes_32.png - https://www.iconninja.com/box-mario-icon-30561

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.

.. |maintainer-Tardo| image:: https://github.com/Tardo.png?size=40px
:target: https://github.com/Tardo
:alt: Tardo

Current `maintainer <https://odoo-community.org/page/maintainer-role>`__:

|maintainer-Tardo|

This module is part of the `OCA/e-commerce <https://github.com/OCA/e-commerce/tree/19.0/website_snippet_product_category>`_ 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_snippet_product_category/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
from . import controllers
from . import models
31 changes: 31 additions & 0 deletions website_snippet_product_category/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# Copyright 2020 Tecnativa - Alexandre Díaz
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl).
{
"name": "Website Snippet Product Category",
"category": "Website",
"summary": "Adds a new snippet to show e-commerce categories",
"version": "19.0.1.0.0",
"license": "LGPL-3",
"website": "https://github.com/OCA/e-commerce",
"author": "Tecnativa, Odoo Community Association (OCA)",
"depends": ["website_sale"],
"data": [
"templates/snippets.xml",
"views/product_public_category.xml",
],
"assets": {
"web.assets_frontend": [
"/website_snippet_product_category/static/src/scss/snippet.scss",
"/website_snippet_product_category/static/src/js/frontend.esm.js",
],
"website.website_builder_assets": [
"/website_snippet_product_category/static/src/js/snippet.options.esm.js",
],
"web.assets_tests": [
"/website_snippet_product_category/static/src/tests/*.esm.js"
],
},
"demo": ["demo/demo.xml", "demo/pages.xml"],
"maintainers": ["Tardo"],
"installable": True,
}
1 change: 1 addition & 0 deletions website_snippet_product_category/controllers/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import website
29 changes: 29 additions & 0 deletions website_snippet_product_category/controllers/website.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Copyright 2020 Tecnativa - Alexandre Díaz
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from odoo import http
from odoo.http import request

from odoo.addons.website.controllers.main import QueryURL


class Website(http.Controller):
@http.route(
["/website_sale/render_product_category"],
type="jsonrpc",
auth="public",
website=True,
)
def render_product_category(self, template, **kwargs):
categories = request.env["product.public.category"].search(
[
("parent_id", "=", False),
("published_in_product_category_snippet", "=", True),
"|",
("snippet_website_ids", "=", False),
("snippet_website_ids", "=", request.website.id),
]
)
keep = QueryURL("/shop", category=0)
return request.env["ir.qweb"]._render(
template, {"object": categories, "keep": keep}
)
69 changes: 69 additions & 0 deletions website_snippet_product_category/demo/demo.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
<?xml version="1.0" encoding="utf-8" ?>
<odoo noupdate="1">
<record id="website_sale.public_category_desks" model="product.public.category">
<field name="published_in_product_category_snippet" eval="True" />
</record>
<record
id="website_sale.public_category_furnitures"
model="product.public.category"
>
<field name="published_in_product_category_snippet" eval="True" />
</record>
<record id="website_sale.public_category_boxes" model="product.public.category">
<field name="published_in_product_category_snippet" eval="True" />
<field
name="image_128"
type="base64"
file="website_snippet_product_category/static/img/boxes_32.png"
/>
</record>
<record id="website_sale.public_category_drawers" model="product.public.category">
<field name="published_in_product_category_snippet" eval="True" />
</record>
<record id="website_sale.public_category_cabinets" model="product.public.category">
<field name="published_in_product_category_snippet" eval="True" />
</record>
<record id="website_sale.public_category_bins" model="product.public.category">
<field name="published_in_product_category_snippet" eval="True" />
</record>
<record id="website_sale.public_category_lamps" model="product.public.category">
<field name="published_in_product_category_snippet" eval="True" />
</record>
<record id="website_sale.public_category_services" model="product.public.category">
<field name="published_in_product_category_snippet" eval="True" />
</record>
<record
id="website_sale.public_category_multimedia"
model="product.public.category"
>
<field name="published_in_product_category_snippet" eval="True" />
</record>
<record id="public_category_boxes_metal" model="product.public.category">
<field name="name">Metal Box</field>
<field name="parent_id" ref="website_sale.public_category_boxes" />
<field name="published_in_product_category_snippet" eval="True" />
</record>
<record id="public_category_boxes_wooden" model="product.public.category">
<field name="name">Wooden Box</field>
<field name="parent_id" ref="website_sale.public_category_boxes" />
<field name="published_in_product_category_snippet" eval="True" />
</record>
<record id="public_category_boxes_metal_spec_a" model="product.public.category">
<field name="name">Spec A</field>
<field name="parent_id" ref="public_category_boxes_metal" />
<field name="published_in_product_category_snippet" eval="True" />
</record>
<record id="public_category_boxes_metal_spec_b" model="product.public.category">
<field name="name">Spec B</field>
<field name="parent_id" ref="public_category_boxes_metal" />
<field name="published_in_product_category_snippet" eval="True" />
</record>
<record
id="public_category_boxes_metal_subspec_b_a"
model="product.public.category"
>
<field name="name">SubSpec B - A</field>
<field name="parent_id" ref="public_category_boxes_metal_spec_b" />
<field name="published_in_product_category_snippet" eval="True" />
</record>
</odoo>
27 changes: 27 additions & 0 deletions website_snippet_product_category/demo/pages.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?xml version="1.0" encoding="utf-8" ?>
<odoo>
<template
id="snippet_product_category_demo_view"
name="Snippet Product Category Test"
>
<t t-call="website.layout">
<div id="wrap">
<section class="s_product_category py-4">
<div class="js_product_category col-12" />
</section>
</div>
</t>
</template>
<record id="snippet_product_category_demo_page" model="website.page">
<field name="is_published">True</field>
<field name="url">/website_snippet_product_category.demo_page</field>
<field name="view_id" ref="snippet_product_category_demo_view" />
</record>
<record id="snippet_product_category_demo_page_link" model="website.menu">
<field name="name">Snippet Product Category Demo</field>
<field name="url">/website_snippet_product_category.demo_page</field>
<field name="parent_id" ref="website.main_menu" />
<field name="sequence" type="int">50</field>
<field name="page_id" ref="snippet_product_category_demo_page" />
</record>
</odoo>
Loading
Loading