Skip to content

Commit

Permalink
Merge PR #1020 into 18.0
Browse files Browse the repository at this point in the history
Signed-off-by pedrobaeza
  • Loading branch information
OCA-git-bot committed Feb 17, 2025
2 parents 5068ae7 + 2453b13 commit 6b75228
Show file tree
Hide file tree
Showing 34 changed files with 1,588 additions and 0 deletions.
143 changes: 143 additions & 0 deletions website_snippet_product_category/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,143 @@
================================
Website Snippet Product Category
================================

..
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:403c2b9204ca8734b5628e1fa3e4a5616ccfa408d56d59a2395967489bdeeb85
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
.. |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
: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/18.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-18-0/e-commerce-18-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=18.0
:alt: Try me on Runboat

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

Adds a new snippet to show e-commerce categories

**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"

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 replacing the ``data-template``
attribute value in the ``s_product_category_options`` view. 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:%2018.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/18.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": "18.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.assets_wysiwyg": [
"/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
26 changes: 26 additions & 0 deletions website_snippet_product_category/controllers/website.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# 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="json",
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),
]
)
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>
76 changes: 76 additions & 0 deletions website_snippet_product_category/i18n/ca.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * website_snippet_product_category
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 12.0\n"
"Report-Msgid-Bugs-To: \n"
"PO-Revision-Date: 2022-03-02 12:17+0000\n"
"Last-Translator: Noel estudillo <[email protected]>\n"
"Language-Team: none\n"
"Language: ca\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: nplurals=2; plural=n != 1;\n"
"X-Generator: Weblate 4.3.2\n"

#. module: website_snippet_product_category
#. odoo-javascript
#: code:addons/website_snippet_product_category/static/src/js/frontend.js:0
#, python-format
msgid ""
"An error occured with this product categories block. If the problem "
"persists, please consider deleting it and adding a new one"
msgstr ""
"S'ha produït un error amb aquest bloc de categories de productes. Si el "
"problema continua, penseu en suprimir-lo i afegir-ne un de nou"

#. module: website_snippet_product_category
#: model:product.public.category,name:website_snippet_product_category.public_category_boxes_metal
msgid "Metal Box"
msgstr "Caixa de metall"

#. module: website_snippet_product_category
#. odoo-javascript
#: code:addons/website_snippet_product_category/static/src/js/frontend.js:0
#, python-format
msgid "No categories were found. Make sure you have categories defined."
msgstr ""
"No s'han trobat categories. Assegureu-vos que teniu categories definides."

#. module: website_snippet_product_category
#: model:ir.model.fields,field_description:website_snippet_product_category.field_product_public_category__published_in_product_category_snippet
msgid "Published in product category snippet"
msgstr "Publicat al fragment de categoria de producte"

#. module: website_snippet_product_category
#: model:website.menu,name:website_snippet_product_category.snippet_product_category_demo_page_link
msgid "Snippet Product Category Demo"
msgstr "Demostració de la categoria de producte del fragment"

#. module: website_snippet_product_category
#: model:product.public.category,name:website_snippet_product_category.public_category_boxes_metal_spec_a
msgid "Spec A"
msgstr "Especificació A"

#. module: website_snippet_product_category
#: model:product.public.category,name:website_snippet_product_category.public_category_boxes_metal_spec_b
msgid "Spec B"
msgstr "Especificació B"

#. module: website_snippet_product_category
#: model:product.public.category,name:website_snippet_product_category.public_category_boxes_metal_subspec_b_a
msgid "SubSpec B - A"
msgstr "Subespecificació B-A"

#. module: website_snippet_product_category
#: model:ir.model,name:website_snippet_product_category.model_product_public_category
msgid "Website Product Category"
msgstr "Categoria de producte del lloc web"

#. module: website_snippet_product_category
#: model:product.public.category,name:website_snippet_product_category.public_category_boxes_wooden
msgid "Wooden Box"
msgstr "Caixa de fusta"
Loading

0 comments on commit 6b75228

Please sign in to comment.