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
48 changes: 29 additions & 19 deletions website_snippet_product_category/README.rst
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
.. 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
================================
Expand All @@ -13,7 +17,7 @@ Website Snippet Product Category
.. |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/licence-LGPL--3-blue.png
.. |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
Expand All @@ -28,7 +32,10 @@ Website Snippet Product Category

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

Adds a new snippet to show e-commerce categories
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**

Expand All @@ -44,6 +51,9 @@ 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
=====
Expand All @@ -59,13 +69,13 @@ 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
- ``.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).
Expand All @@ -78,10 +88,10 @@ 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
- 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
===========
Expand All @@ -104,13 +114,13 @@ Authors
Contributors
------------

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

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

Other credits
-------------
Expand Down
3 changes: 3 additions & 0 deletions website_snippet_product_category/controllers/website.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ def render_product_category(self, template, **kwargs):
[
("parent_id", "=", False),
("published_in_product_category_snippet", "=", True),
"|",
("snippet_website_ids", "=", False),
("snippet_website_ids", "=", request.website.id),
]
)
keep = QueryURL("/shop", category=0)
Expand Down
10 changes: 10 additions & 0 deletions website_snippet_product_category/models/product_public_category.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,13 @@ class ProductPublicCategory(models.Model):
published_in_product_category_snippet = fields.Boolean(
"Published in product category snippet", copy=False
)
snippet_website_ids = fields.Many2many(
"website",
"product_public_category_snippet_website_rel",
"product_public_category_id",
"website_id",
string="Websites for category snippet",
help="Show this category in the product category snippet only on the "
"selected websites. Leave empty to show it on all websites.",
copy=False,
)
3 changes: 3 additions & 0 deletions website_snippet_product_category/readme/CONFIGURE.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,6 @@ 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.
5 changes: 4 additions & 1 deletion website_snippet_product_category/readme/DESCRIPTION.md
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
Adds a new snippet to show e-commerce categories
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.
41 changes: 26 additions & 15 deletions website_snippet_product_category/static/description/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="generator" content="Docutils: https://docutils.sourceforge.io/" />
<title>Website Snippet Product Category</title>
<title>README.rst</title>
<style type="text/css">

/*
Expand Down Expand Up @@ -360,17 +360,24 @@
</style>
</head>
<body>
<div class="document" id="website-snippet-product-category">
<h1 class="title">Website Snippet Product Category</h1>
<div class="document">


<a class="reference external image-reference" href="https://odoo-community.org/get-involved?utm_source=readme">
<img alt="Odoo Community Association" src="https://odoo-community.org/readme-banner-image" />
</a>
<div class="section" id="website-snippet-product-category">
<h1>Website Snippet Product Category</h1>
<!-- !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:403c2b9204ca8734b5628e1fa3e4a5616ccfa408d56d59a2395967489bdeeb85
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
<p><a class="reference external image-reference" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external image-reference" href="http://www.gnu.org/licenses/lgpl-3.0-standalone.html"><img alt="License: LGPL-3" src="https://img.shields.io/badge/licence-LGPL--3-blue.png" /></a> <a class="reference external image-reference" href="https://github.com/OCA/e-commerce/tree/17.0/website_snippet_product_category"><img alt="OCA/e-commerce" src="https://img.shields.io/badge/github-OCA%2Fe--commerce-lightgray.png?logo=github" /></a> <a class="reference external image-reference" href="https://translation.odoo-community.org/projects/e-commerce-17-0/e-commerce-17-0-website_snippet_product_category"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external image-reference" href="https://runboat.odoo-community.org/builds?repo=OCA/e-commerce&amp;target_branch=17.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
<p>Adds a new snippet to show e-commerce categories</p>
<p><a class="reference external image-reference" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external image-reference" href="http://www.gnu.org/licenses/lgpl-3.0-standalone.html"><img alt="License: LGPL-3" src="https://img.shields.io/badge/license-LGPL--3-blue.png" /></a> <a class="reference external image-reference" href="https://github.com/OCA/e-commerce/tree/17.0/website_snippet_product_category"><img alt="OCA/e-commerce" src="https://img.shields.io/badge/github-OCA%2Fe--commerce-lightgray.png?logo=github" /></a> <a class="reference external image-reference" href="https://translation.odoo-community.org/projects/e-commerce-17-0/e-commerce-17-0-website_snippet_product_category"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external image-reference" href="https://runboat.odoo-community.org/builds?repo=OCA/e-commerce&amp;target_branch=17.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
<p>Adds a new snippet to show e-commerce categories.</p>
<p>The snippet only displays categories explicitly enabled for it, and can
optionally restrict them to selected websites.</p>
<p><strong>Table of contents</strong></p>
<div class="contents local topic" id="contents">
<ul class="simple">
Expand All @@ -391,17 +398,20 @@ <h1 class="title">Website Snippet Product Category</h1>
</ul>
</div>
<div class="section" id="configuration">
<h1><a class="toc-backref" href="#toc-entry-1">Configuration</a></h1>
<h2><a class="toc-backref" href="#toc-entry-1">Configuration</a></h2>
<p>You can select what categories can be shown by the snippet and an image
for the category:</p>
<ol class="arabic simple">
<li>Go to website &gt; eCommerce &gt; eCommerce Categories</li>
<li>Create or Edit one</li>
<li>You can see a new options “Published in product category snippet”</li>
<li>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.</li>
</ol>
</div>
<div class="section" id="usage">
<h1><a class="toc-backref" href="#toc-entry-2">Usage</a></h1>
<h2><a class="toc-backref" href="#toc-entry-2">Usage</a></h2>
<ol class="arabic simple">
<li>Go to website (frontend)</li>
<li>Press ‘Edit’ button</li>
Expand All @@ -410,7 +420,7 @@ <h1><a class="toc-backref" href="#toc-entry-2">Usage</a></h1>
<li>Save changes</li>
</ol>
<div class="section" id="theming">
<h2><a class="toc-backref" href="#toc-entry-3">Theming</a></h2>
<h3><a class="toc-backref" href="#toc-entry-3">Theming</a></h3>
<p>CSS Classes:</p>
<ul class="simple">
<li><tt class="docutils literal">.categ_container</tt> &gt; The container per master category</li>
Expand All @@ -430,7 +440,7 @@ <h2><a class="toc-backref" href="#toc-entry-3">Theming</a></h2>
</div>
</div>
<div class="section" id="known-issues-roadmap">
<h1><a class="toc-backref" href="#toc-entry-4">Known issues / Roadmap</a></h1>
<h2><a class="toc-backref" href="#toc-entry-4">Known issues / Roadmap</a></h2>
<ul class="simple">
<li>The snippet shows a maximum of 4 levels by design.</li>
<li>Add a option to configure the initial level</li>
Expand All @@ -439,23 +449,23 @@ <h1><a class="toc-backref" href="#toc-entry-4">Known issues / Roadmap</a></h1>
</ul>
</div>
<div class="section" id="bug-tracker">
<h1><a class="toc-backref" href="#toc-entry-5">Bug Tracker</a></h1>
<h2><a class="toc-backref" href="#toc-entry-5">Bug Tracker</a></h2>
<p>Bugs are tracked on <a class="reference external" href="https://github.com/OCA/e-commerce/issues">GitHub Issues</a>.
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
<a class="reference external" href="https://github.com/OCA/e-commerce/issues/new?body=module:%20website_snippet_product_category%0Aversion:%2017.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
<p>Do not contact contributors directly about support or help with technical issues.</p>
</div>
<div class="section" id="credits">
<h1><a class="toc-backref" href="#toc-entry-6">Credits</a></h1>
<h2><a class="toc-backref" href="#toc-entry-6">Credits</a></h2>
<div class="section" id="authors">
<h2><a class="toc-backref" href="#toc-entry-7">Authors</a></h2>
<h3><a class="toc-backref" href="#toc-entry-7">Authors</a></h3>
<ul class="simple">
<li>Tecnativa</li>
</ul>
</div>
<div class="section" id="contributors">
<h2><a class="toc-backref" href="#toc-entry-8">Contributors</a></h2>
<h3><a class="toc-backref" href="#toc-entry-8">Contributors</a></h3>
<ul class="simple">
<li><a class="reference external" href="https://www.tecnativa.com">Tecnativa</a>:<ul>
<li>Alexandre D. Díaz</li>
Expand All @@ -468,11 +478,11 @@ <h2><a class="toc-backref" href="#toc-entry-8">Contributors</a></h2>
</ul>
</div>
<div class="section" id="other-credits">
<h2><a class="toc-backref" href="#toc-entry-9">Other credits</a></h2>
<h3><a class="toc-backref" href="#toc-entry-9">Other credits</a></h3>
<p>static/img/boxes_32.png - <a class="reference external" href="https://www.iconninja.com/box-mario-icon-30561">https://www.iconninja.com/box-mario-icon-30561</a></p>
</div>
<div class="section" id="maintainers">
<h2><a class="toc-backref" href="#toc-entry-10">Maintainers</a></h2>
<h3><a class="toc-backref" href="#toc-entry-10">Maintainers</a></h3>
<p>This module is maintained by the OCA.</p>
<a class="reference external image-reference" href="https://odoo-community.org">
<img alt="Odoo Community Association" src="https://odoo-community.org/logo.png" />
Expand All @@ -487,5 +497,6 @@ <h2><a class="toc-backref" href="#toc-entry-10">Maintainers</a></h2>
</div>
</div>
</div>
</div>
</body>
</html>
12 changes: 10 additions & 2 deletions website_snippet_product_category/templates/snippets.xml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
<div
t-attf-class="categ_tree_level {{'pb-2 main_tree_level text-primary text-uppercase' if cur_level == 1 else ''}} {{cur_level &gt; 2 and 'ps-'+str(min((cur_level-2)*2, 5))}}"
t-att-data-tree-level="cur_level"
t-if="category.published_in_product_category_snippet"
>
<div class="d-flex d-flex-row">
<div
Expand All @@ -46,7 +45,16 @@
<t
t-call="website_snippet_product_category.s_product_category_items_recursive"
>
<t t-set="categories" t-value="category.child_id" />
<t
t-set="categories"
t-value="category.child_id.filtered(
lambda c: c.published_in_product_category_snippet
and (
not c.snippet_website_ids
or request.website in c.snippet_website_ids
)
)"
/>
<t t-set="cur_level" t-value="cur_level+1" />
</t>
</t>
Expand Down
13 changes: 13 additions & 0 deletions website_snippet_product_category/views/product_public_category.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,13 @@
name="published_in_product_category_snippet"
widget="boolean_toggle"
/>
<field
name="snippet_website_ids"
options="{'no_create': True}"
widget="many2many_tags"
groups="website.group_multi_website"
placeholder="Empty means all websites"
/>
</field>
</field>
</record>
Expand All @@ -23,6 +30,12 @@
name="published_in_product_category_snippet"
widget="boolean_toggle"
/>
<field
name="snippet_website_ids"
groups="website.group_multi_website"
widget="many2many_tags"
optional="show"
/>
</field>
</field>
</record>
Expand Down
Loading