Añadidos módulos de OCA/e-commerce para la tienda online

This commit is contained in:
santiky 2021-09-14 14:07:34 +02:00
parent 10bfdb5a49
commit c14ed5b4ef
Signed by: snt
GPG key ID: A9FD34930EADBE71
99 changed files with 5359 additions and 0 deletions

View file

@ -0,0 +1,136 @@
================================
Website Snippet Product Category
================================
.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
.. |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/12.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-12-0/e-commerce-12-0-website_snippet_product_category
:alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png
:target: https://runbot.odoo-community.org/runbot/113/12.0
:alt: Try me on Runbot
|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:
#. Go to website (backend) > Configuration > Products > eCommerce Categories
#. Create or Edit one
#. You can see two new options "Website Published" and "Category Image"
Usage
=====
#. Go to website (frontend)
#. Press 'Edit' button
#. Drag the 'Product Category' snippet to the place of the website that you want
#. 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 smashing it by providing a detailed and welcomed
`feedback <https://github.com/OCA/e-commerce/issues/new?body=module:%20website_snippet_product_category%0Aversion:%2012.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
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/12.0/website_snippet_product_category>`_ project on GitHub.
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

View file

@ -0,0 +1,2 @@
from . import controllers
from . import models

View file

@ -0,0 +1,23 @@
# 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": "12.0.1.2.0",
"license": "LGPL-3",
"website": "https://github.com/OCA/e-commerce",
"author": "Tecnativa, Odoo Community Association (OCA)",
"depends": ["website_sale"],
"data": [
"templates/assets.xml",
"templates/snippets.xml",
"views/product_public_category.xml",
],
"demo": [
"demo/demo.xml",
"demo/pages.xml",
],
"maintainers": ["Tardo"],
"installable": True,
}

View file

@ -0,0 +1 @@
from . import website

View file

@ -0,0 +1,24 @@
# 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), ("website_published", "=", True)]
)
keep = QueryURL("/shop", category=0)
return request.website.viewref(template).render({
"object": categories,
"keep": keep
})

View file

@ -0,0 +1,62 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo noupdate="1">
<record id="website_sale.Components" model="product.public.category">
<field name="website_published" eval="True"/>
</record>
<record id="website_sale.public_category_boxes" model="product.public.category">
<field name="website_published" eval="True"/>
<field name="image_small" type="base64" file="website_snippet_product_category/static/img/boxes_32.png" />
</record>
<record id="website_sale.public_category_desks" model="product.public.category">
<field name="website_published" eval="True"/>
</record>
<record id="website_sale.public_category_cabinets" model="product.public.category">
<field name="website_published" eval="True"/>
</record>
<record id="website_sale.public_category_bins" model="product.public.category">
<field name="website_published" eval="True"/>
</record>
<record id="website_sale.public_category_chairs" model="product.public.category">
<field name="website_published" eval="True"/>
</record>
<record id="website_sale.public_category_drawers" model="product.public.category">
<field name="website_published" eval="True"/>
</record>
<record id="website_sale.public_category_lamps" model="product.public.category">
<field name="website_published" eval="True"/>
</record>
<record id="website_sale.public_category_multimedia" model="product.public.category">
<field name="website_published" eval="True"/>
</record>
<record id="website_sale.services" model="product.public.category">
<field name="website_published" 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="website_published" 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="website_published" 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="website_published" 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="website_published" 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="website_published" eval="True"/>
</record>
</odoo>

View file

@ -0,0 +1,28 @@
<?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" class="oe_structure oe_empty">
<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="website_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>

View file

@ -0,0 +1,69 @@
# 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: 2021-01-20 20:45+0000\n"
"Last-Translator: claudiagn <claudia.gargallo@qubiq.es>\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
#. openerp-web
#: code:addons/website_snippet_product_category/static/src/js/frontend.js:64
#, 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
#. openerp-web
#: code:addons/website_snippet_product_category/static/src/js/frontend.js:46
#, 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: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"

View file

@ -0,0 +1,68 @@
# 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: 2020-11-03 13:08+0000\n"
"Last-Translator: claudiagn <claudia.gargallo@qubiq.es>\n"
"Language-Team: none\n"
"Language: es\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 3.10\n"
#. module: website_snippet_product_category
#. openerp-web
#: code:addons/website_snippet_product_category/static/src/js/frontend.js:64
#, 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 ""
"Ocurrió un error con este bloque de categorías de productos. Si el problema "
"persiste, considere eliminarlo y agregar uno nuevo"
#. module: website_snippet_product_category
#: model:product.public.category,name:website_snippet_product_category.public_category_boxes_metal
msgid "Metal Box"
msgstr "Caja de metal"
#. module: website_snippet_product_category
#. openerp-web
#: code:addons/website_snippet_product_category/static/src/js/frontend.js:46
#, python-format
msgid "No categories were found. Make sure you have categories defined."
msgstr "No se encontraron categorías. Asegúrese de tener categorías definidas."
#. 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ón de categoría de producto de fragmento"
#. module: website_snippet_product_category
#: model:product.public.category,name:website_snippet_product_category.public_category_boxes_metal_spec_a
msgid "Spec A"
msgstr "Spec 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 "Spec 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 "SubSpec B - A"
#. module: website_snippet_product_category
#: model:ir.model,name:website_snippet_product_category.model_product_public_category
msgid "Website Product Category"
msgstr "Categoría de producto para la página web"
#. module: website_snippet_product_category
#: model:product.public.category,name:website_snippet_product_category.public_category_boxes_wooden
msgid "Wooden Box"
msgstr "Caja de madera"

View file

@ -0,0 +1,70 @@
# 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: 2020-11-23 15:55+0000\n"
"Last-Translator: Yann Papouin <y.papouin@dec-industrie.com>\n"
"Language-Team: none\n"
"Language: fr\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 3.10\n"
#. module: website_snippet_product_category
#. openerp-web
#: code:addons/website_snippet_product_category/static/src/js/frontend.js:64
#, 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 ""
"Une erreur est survenue avec ce bloc de catégories d'articles. Si le "
"problème persiste, merci de considérer la suppression de ce bloc et l'ajout "
"d'un nouveau"
#. module: website_snippet_product_category
#: model:product.public.category,name:website_snippet_product_category.public_category_boxes_metal
msgid "Metal Box"
msgstr "Boite en métal"
#. module: website_snippet_product_category
#. openerp-web
#: code:addons/website_snippet_product_category/static/src/js/frontend.js:46
#, python-format
msgid "No categories were found. Make sure you have categories defined."
msgstr ""
"Aucune catégorie n'a été trouvée. Assurez-vous d'avoir défini des catégories."
#. 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 "Démonstration du bloc catégorie d'articles"
#. module: website_snippet_product_category
#: model:product.public.category,name:website_snippet_product_category.public_category_boxes_metal_spec_a
msgid "Spec A"
msgstr "Type 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 "Type 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 "Sous-type B-A"
#. module: website_snippet_product_category
#: model:ir.model,name:website_snippet_product_category.model_product_public_category
msgid "Website Product Category"
msgstr "Catégorie d'articles du site Web"
#. module: website_snippet_product_category
#: model:product.public.category,name:website_snippet_product_category.public_category_boxes_wooden
msgid "Wooden Box"
msgstr "Boite en bois"

View file

@ -0,0 +1,68 @@
# 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: 2020-12-15 13:19+0000\n"
"Last-Translator: Bosd <c5e2fd43-d292-4c90-9d1f-74ff3436329a@anonaddy.me>\n"
"Language-Team: none\n"
"Language: nl\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
#. openerp-web
#: code:addons/website_snippet_product_category/static/src/js/frontend.js:64
#, 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 ""
#. module: website_snippet_product_category
#: model:product.public.category,name:website_snippet_product_category.public_category_boxes_metal
msgid "Metal Box"
msgstr ""
#. module: website_snippet_product_category
#. openerp-web
#: code:addons/website_snippet_product_category/static/src/js/frontend.js:46
#, python-format
msgid "No categories were found. Make sure you have categories defined."
msgstr ""
"Er zijn geen categorieen gevonden. Zorg er voor dat er categorieen zijn "
"aangemaakt."
#. 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 ""
#. module: website_snippet_product_category
#: model:product.public.category,name:website_snippet_product_category.public_category_boxes_metal_spec_a
msgid "Spec A"
msgstr ""
#. module: website_snippet_product_category
#: model:product.public.category,name:website_snippet_product_category.public_category_boxes_metal_spec_b
msgid "Spec B"
msgstr ""
#. 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 ""
#. module: website_snippet_product_category
#: model:ir.model,name:website_snippet_product_category.model_product_public_category
msgid "Website Product Category"
msgstr "Website Product Categorie"
#. module: website_snippet_product_category
#: model:product.public.category,name:website_snippet_product_category.public_category_boxes_wooden
msgid "Wooden Box"
msgstr ""

View file

@ -0,0 +1,2 @@
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl).
from . import product_public_category

View file

@ -0,0 +1,8 @@
# Copyright 2020 Tecnativa - Alexandre Díaz
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from odoo import models
class ProductPublicCategory(models.Model):
_inherit = ["product.public.category", "website.published.mixin"]
_name = "product.public.category"

View file

@ -0,0 +1,5 @@
You can select what categories can be shown by the snippet and an image for the category:
#. Go to website (backend) > Configuration > Products > eCommerce Categories
#. Create or Edit one
#. You can see two new options "Website Published" and "Category Image"

View file

@ -0,0 +1,4 @@
* `Tecnativa <https://www.tecnativa.com>`__:
* Alexandre D. Díaz
* Pedro M. Baeza

View file

@ -0,0 +1 @@
static/img/boxes_32.png - https://www.iconninja.com/box-mario-icon-30561

View file

@ -0,0 +1 @@
Adds a new snippet to show e-commerce categories

View file

@ -0,0 +1,4 @@
* 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

View file

@ -0,0 +1,26 @@
#. Go to website (frontend)
#. Press 'Edit' button
#. Drag the 'Product Category' snippet to the place of the website that you want
#. 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``.

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.2 KiB

View file

@ -0,0 +1,481 @@
<?xml version="1.0" encoding="utf-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="generator" content="Docutils 0.15.1: http://docutils.sourceforge.net/" />
<title>Website Snippet Product Category</title>
<style type="text/css">
/*
:Author: David Goodger (goodger@python.org)
:Id: $Id: html4css1.css 7952 2016-07-26 18:15:59Z milde $
:Copyright: This stylesheet has been placed in the public domain.
Default cascading style sheet for the HTML output of Docutils.
See http://docutils.sf.net/docs/howto/html-stylesheets.html for how to
customize this style sheet.
*/
/* used to remove borders from tables and images */
.borderless, table.borderless td, table.borderless th {
border: 0 }
table.borderless td, table.borderless th {
/* Override padding for "table.docutils td" with "! important".
The right padding separates the table cells. */
padding: 0 0.5em 0 0 ! important }
.first {
/* Override more specific margin styles with "! important". */
margin-top: 0 ! important }
.last, .with-subtitle {
margin-bottom: 0 ! important }
.hidden {
display: none }
.subscript {
vertical-align: sub;
font-size: smaller }
.superscript {
vertical-align: super;
font-size: smaller }
a.toc-backref {
text-decoration: none ;
color: black }
blockquote.epigraph {
margin: 2em 5em ; }
dl.docutils dd {
margin-bottom: 0.5em }
object[type="image/svg+xml"], object[type="application/x-shockwave-flash"] {
overflow: hidden;
}
/* Uncomment (and remove this text!) to get bold-faced definition list terms
dl.docutils dt {
font-weight: bold }
*/
div.abstract {
margin: 2em 5em }
div.abstract p.topic-title {
font-weight: bold ;
text-align: center }
div.admonition, div.attention, div.caution, div.danger, div.error,
div.hint, div.important, div.note, div.tip, div.warning {
margin: 2em ;
border: medium outset ;
padding: 1em }
div.admonition p.admonition-title, div.hint p.admonition-title,
div.important p.admonition-title, div.note p.admonition-title,
div.tip p.admonition-title {
font-weight: bold ;
font-family: sans-serif }
div.attention p.admonition-title, div.caution p.admonition-title,
div.danger p.admonition-title, div.error p.admonition-title,
div.warning p.admonition-title, .code .error {
color: red ;
font-weight: bold ;
font-family: sans-serif }
/* Uncomment (and remove this text!) to get reduced vertical space in
compound paragraphs.
div.compound .compound-first, div.compound .compound-middle {
margin-bottom: 0.5em }
div.compound .compound-last, div.compound .compound-middle {
margin-top: 0.5em }
*/
div.dedication {
margin: 2em 5em ;
text-align: center ;
font-style: italic }
div.dedication p.topic-title {
font-weight: bold ;
font-style: normal }
div.figure {
margin-left: 2em ;
margin-right: 2em }
div.footer, div.header {
clear: both;
font-size: smaller }
div.line-block {
display: block ;
margin-top: 1em ;
margin-bottom: 1em }
div.line-block div.line-block {
margin-top: 0 ;
margin-bottom: 0 ;
margin-left: 1.5em }
div.sidebar {
margin: 0 0 0.5em 1em ;
border: medium outset ;
padding: 1em ;
background-color: #ffffee ;
width: 40% ;
float: right ;
clear: right }
div.sidebar p.rubric {
font-family: sans-serif ;
font-size: medium }
div.system-messages {
margin: 5em }
div.system-messages h1 {
color: red }
div.system-message {
border: medium outset ;
padding: 1em }
div.system-message p.system-message-title {
color: red ;
font-weight: bold }
div.topic {
margin: 2em }
h1.section-subtitle, h2.section-subtitle, h3.section-subtitle,
h4.section-subtitle, h5.section-subtitle, h6.section-subtitle {
margin-top: 0.4em }
h1.title {
text-align: center }
h2.subtitle {
text-align: center }
hr.docutils {
width: 75% }
img.align-left, .figure.align-left, object.align-left, table.align-left {
clear: left ;
float: left ;
margin-right: 1em }
img.align-right, .figure.align-right, object.align-right, table.align-right {
clear: right ;
float: right ;
margin-left: 1em }
img.align-center, .figure.align-center, object.align-center {
display: block;
margin-left: auto;
margin-right: auto;
}
table.align-center {
margin-left: auto;
margin-right: auto;
}
.align-left {
text-align: left }
.align-center {
clear: both ;
text-align: center }
.align-right {
text-align: right }
/* reset inner alignment in figures */
div.align-right {
text-align: inherit }
/* div.align-center * { */
/* text-align: left } */
.align-top {
vertical-align: top }
.align-middle {
vertical-align: middle }
.align-bottom {
vertical-align: bottom }
ol.simple, ul.simple {
margin-bottom: 1em }
ol.arabic {
list-style: decimal }
ol.loweralpha {
list-style: lower-alpha }
ol.upperalpha {
list-style: upper-alpha }
ol.lowerroman {
list-style: lower-roman }
ol.upperroman {
list-style: upper-roman }
p.attribution {
text-align: right ;
margin-left: 50% }
p.caption {
font-style: italic }
p.credits {
font-style: italic ;
font-size: smaller }
p.label {
white-space: nowrap }
p.rubric {
font-weight: bold ;
font-size: larger ;
color: maroon ;
text-align: center }
p.sidebar-title {
font-family: sans-serif ;
font-weight: bold ;
font-size: larger }
p.sidebar-subtitle {
font-family: sans-serif ;
font-weight: bold }
p.topic-title {
font-weight: bold }
pre.address {
margin-bottom: 0 ;
margin-top: 0 ;
font: inherit }
pre.literal-block, pre.doctest-block, pre.math, pre.code {
margin-left: 2em ;
margin-right: 2em }
pre.code .ln { color: grey; } /* line numbers */
pre.code, code { background-color: #eeeeee }
pre.code .comment, code .comment { color: #5C6576 }
pre.code .keyword, code .keyword { color: #3B0D06; font-weight: bold }
pre.code .literal.string, code .literal.string { color: #0C5404 }
pre.code .name.builtin, code .name.builtin { color: #352B84 }
pre.code .deleted, code .deleted { background-color: #DEB0A1}
pre.code .inserted, code .inserted { background-color: #A3D289}
span.classifier {
font-family: sans-serif ;
font-style: oblique }
span.classifier-delimiter {
font-family: sans-serif ;
font-weight: bold }
span.interpreted {
font-family: sans-serif }
span.option {
white-space: nowrap }
span.pre {
white-space: pre }
span.problematic {
color: red }
span.section-subtitle {
/* font-size relative to parent (h1..h6 element) */
font-size: 80% }
table.citation {
border-left: solid 1px gray;
margin-left: 1px }
table.docinfo {
margin: 2em 4em }
table.docutils {
margin-top: 0.5em ;
margin-bottom: 0.5em }
table.footnote {
border-left: solid 1px black;
margin-left: 1px }
table.docutils td, table.docutils th,
table.docinfo td, table.docinfo th {
padding-left: 0.5em ;
padding-right: 0.5em ;
vertical-align: top }
table.docutils th.field-name, table.docinfo th.docinfo-name {
font-weight: bold ;
text-align: left ;
white-space: nowrap ;
padding-left: 0 }
/* "booktabs" style (no vertical lines) */
table.docutils.booktabs {
border: 0px;
border-top: 2px solid;
border-bottom: 2px solid;
border-collapse: collapse;
}
table.docutils.booktabs * {
border: 0px;
}
table.docutils.booktabs th {
border-bottom: thin solid;
text-align: left;
}
h1 tt.docutils, h2 tt.docutils, h3 tt.docutils,
h4 tt.docutils, h5 tt.docutils, h6 tt.docutils {
font-size: 100% }
ul.auto-toc {
list-style-type: none }
</style>
</head>
<body>
<div class="document" id="website-snippet-product-category">
<h1 class="title">Website Snippet Product Category</h1>
<!-- !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
<p><a class="reference external" 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" 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" href="https://github.com/OCA/e-commerce/tree/12.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" href="https://translation.odoo-community.org/projects/e-commerce-12-0/e-commerce-12-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" href="https://runbot.odoo-community.org/runbot/113/12.0"><img alt="Try me on Runbot" src="https://img.shields.io/badge/runbot-Try%20me-875A7B.png" /></a></p>
<p>Adds a new snippet to show e-commerce categories</p>
<p><strong>Table of contents</strong></p>
<div class="contents local topic" id="contents">
<ul class="simple">
<li><a class="reference internal" href="#configuration" id="id1">Configuration</a></li>
<li><a class="reference internal" href="#usage" id="id2">Usage</a><ul>
<li><a class="reference internal" href="#theming" id="id3">Theming</a></li>
</ul>
</li>
<li><a class="reference internal" href="#known-issues-roadmap" id="id4">Known issues / Roadmap</a></li>
<li><a class="reference internal" href="#bug-tracker" id="id5">Bug Tracker</a></li>
<li><a class="reference internal" href="#credits" id="id6">Credits</a><ul>
<li><a class="reference internal" href="#authors" id="id7">Authors</a></li>
<li><a class="reference internal" href="#contributors" id="id8">Contributors</a></li>
<li><a class="reference internal" href="#other-credits" id="id9">Other credits</a></li>
<li><a class="reference internal" href="#maintainers" id="id10">Maintainers</a></li>
</ul>
</li>
</ul>
</div>
<div class="section" id="configuration">
<h1><a class="toc-backref" href="#id1">Configuration</a></h1>
<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 (backend) &gt; Configuration &gt; Products &gt; eCommerce Categories</li>
<li>Create or Edit one</li>
<li>You can see two new options “Website Published” and “Category Image”</li>
</ol>
</div>
<div class="section" id="usage">
<h1><a class="toc-backref" href="#id2">Usage</a></h1>
<ol class="arabic simple">
<li>Go to website (frontend)</li>
<li>Press Edit button</li>
<li>Drag the Product Category snippet to the place of the website that you want</li>
<li>Save changes</li>
</ol>
<div class="section" id="theming">
<h2><a class="toc-backref" href="#id3">Theming</a></h2>
<p>CSS Classes:</p>
<ul class="simple">
<li><tt class="docutils literal">.categ_container</tt> &gt; The container per master category</li>
<li><tt class="docutils literal">.categ_scroll_wrapper</tt> &gt; The scrollable container wrapper</li>
<li><tt class="docutils literal">.categ_scroll</tt> &gt; The scrollable container</li>
<li><tt class="docutils literal">.categ_tree_level</tt> &gt; The category row (image + text)</li>
<li><tt class="docutils literal">.main_tree_level</tt> &gt; The first category row level displayed</li>
<li><tt class="docutils literal">.categ_link</tt> &gt; The link of the category row</li>
<li><tt class="docutils literal">.categ_img</tt> &gt; The container of the icon of the category row</li>
</ul>
<p>You can use data-tree-level attribute to select the category row of a selected
level (1-4 by design).</p>
<p>Also you can replace the entire template replacing the <tt class="docutils literal"><span class="pre">data-template</span></tt> attribute value
in the <tt class="docutils literal">s_product_category_options</tt> view. You only need know that the name
of the variable that have all the categories is called <tt class="docutils literal">object</tt>.</p>
</div>
</div>
<div class="section" id="known-issues-roadmap">
<h1><a class="toc-backref" href="#id4">Known issues / Roadmap</a></h1>
<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>
<li>Add a option to select how many levels can be represented</li>
<li>Handle large amounts of categories</li>
</ul>
</div>
<div class="section" id="bug-tracker">
<h1><a class="toc-backref" href="#id5">Bug Tracker</a></h1>
<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 smashing 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:%2012.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="#id6">Credits</a></h1>
<div class="section" id="authors">
<h2><a class="toc-backref" href="#id7">Authors</a></h2>
<ul class="simple">
<li>Tecnativa</li>
</ul>
</div>
<div class="section" id="contributors">
<h2><a class="toc-backref" href="#id8">Contributors</a></h2>
<ul class="simple">
<li><a class="reference external" href="https://www.tecnativa.com">Tecnativa</a>:<ul>
<li>Alexandre D. Díaz</li>
<li>Pedro M. Baeza</li>
</ul>
</li>
</ul>
</div>
<div class="section" id="other-credits">
<h2><a class="toc-backref" href="#id9">Other credits</a></h2>
<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="#id10">Maintainers</a></h2>
<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" /></a>
<p>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.</p>
<p>Current <a class="reference external" href="https://odoo-community.org/page/maintainer-role">maintainer</a>:</p>
<p><a class="reference external" href="https://github.com/Tardo"><img alt="Tardo" src="https://github.com/Tardo.png?size=40px" /></a></p>
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/e-commerce/tree/12.0/website_snippet_product_category">OCA/e-commerce</a> project on GitHub.</p>
<p>You are welcome to contribute. To learn how please visit <a class="reference external" href="https://odoo-community.org/page/Contribute">https://odoo-community.org/page/Contribute</a>.</p>
</div>
</div>
</div>
</body>
</html>

Binary file not shown.

After

Width:  |  Height:  |  Size: 697 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 372 B

View file

@ -0,0 +1,86 @@
// Copyright 2020 Tecnativa - Alexandre Díaz
// License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl).
odoo.define("website_snippet_product_category.s_product_category", function (require) {
"use strict";
var core = require("web.core");
var sAnimation = require("website.content.snippets.animation");
var _t = core._t;
sAnimation.registry.js_product_category = sAnimation.Class.extend({
selector: ".js_product_category",
/**
* Asynchronous server side template rendering
* @override
*/
start: function () {
var self = this;
var template =
this.$target.data("template") ||
"website_snippet_product_category.s_product_category_items";
// Prevent user edition
this.$target.attr("contenteditable", "False");
var def = this._rpc({
route: "/website_sale/render_product_category",
params: {
template: template,
},
})
.then(
function (object_html) {
var $object_html = $(object_html);
var count = $object_html
.find("input[name='object_count']")
.val();
if (!count) {
self.$target.append(
$("<div/>").append(
$("<div/>", {
class:
"alert alert-warning" +
" alert-dismissible text-center",
text: _t(
"No categories were found. Make" +
" sure you have categories" +
" defined."
),
})
)
);
return;
}
self.$target.html($object_html);
},
function () {
if (self.editableMode) {
self.$target.append(
$("<p/>", {
class: "text-danger",
text: _t(
"An error occured with this product" +
" categories block. If the problem" +
" persists, please consider deleting" +
" it and adding a new one"
),
})
);
}
}
);
return $.when(this._super.apply(this, arguments), def);
},
/**
* @override
*/
destroy: function () {
this.$target.empty();
this._super.apply(this, arguments);
},
});
});

View file

@ -0,0 +1,17 @@
// Copyright 2020 Tecnativa - Alexandre Díaz
// License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl).
odoo.define("website_snippet_carousel_product.snippet_options", function (require) {
"use strict";
var options = require("web_editor.snippets.options");
options.registry.js_product_category = options.Class.extend({
/**
* @override
*/
cleanForSave: function () {
this._super.apply(this, arguments);
this.$target.empty();
}
});
});

View file

@ -0,0 +1,37 @@
.categ_container {
.categ_scroll_wrapper {
border: 0 solid $border-color;
border-width: 0 1px 0 0;
}
.categ_scroll {
overflow: hidden;
overflow-y: auto;
}
.categ_img img {
width: 1.4em;
}
.categ_tree_level {
&[data-tree-level="2"] {
font-size: 0.9em;
.categ_link {
text-transform: capitalize;
color: $gray-800;
}
}
&[data-tree-level="3"] {
font-size: 0.8em;
.categ_link {
text-transform: capitalize;
color: $gray-700;
}
}
&[data-tree-level="4"] {
font-size: 0.7em;
.categ_link {
text-transform: lowercase;
color: $gray-600;
}
}
}
}

View file

@ -0,0 +1,27 @@
<?xml version="1.0" encoding="utf-8" ?>
<odoo>
<template id="assets_frontend" inherit_id="website.assets_frontend">
<xpath expr="link[last()]" position="after">
<link
rel="stylesheet"
type="text/css"
href="/website_snippet_product_category/static/src/scss/snippet.scss"
/>
</xpath>
<xpath expr="." position="inside">
<script
type="text/javascript"
src="/website_snippet_product_category/static/src/js/frontend.js"
/>
</xpath>
</template>
<template id="assets_editor" inherit_id="web_editor.assets_editor">
<xpath expr="script[last()]" position="after">
<script
type="text/javascript"
src="/website_snippet_product_category/static/src/js/snippet.options.js"
/>
</xpath>
</template>
</odoo>

View file

@ -0,0 +1,85 @@
<?xml version="1.0" encoding="utf-8" ?>
<odoo>
<template id="snippets" inherit_id="website.snippets">
<xpath
expr="//div[@id='snippet_feature']//div[hasclass('o_panel_body')]"
position="inside"
>
<t
t-snippet="website_snippet_product_category.s_product_category"
t-thumbnail="/website_snippet_product_category/static/src/img/s_product_category.png"
/>
</xpath>
</template>
<!-- Snippet Product Category -->
<template id="s_product_category" name="Product Category">
<section class="s_product_category py-4">
<div class="js_product_category col-12" />
</section>
</template>
<template id="s_product_category_items_recursive">
<t
t-foreach="categories.filtered('website_published')"
t-as="category"
t-if="categories and cur_level &lt;= 4"
>
<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 'pl-'+str(min((cur_level-2)*2, 5))}}"
t-att-data-tree-level="cur_level"
>
<div class="d-flex d-flex-row">
<div
t-if="category.image_small"
t-field="category.image_small"
class="categ_img pr-1"
t-options="{'widget': 'image','resize': '24x24' }"
/>
<a
t-att-href="keep('/shop/category/' + slug(category), category=0)"
class="categ_link w-100"
t-field="category.name"
t-att-title="category.name"
/>
</div>
</div>
<t
t-call="website_snippet_product_category.s_product_category_items_recursive"
>
<t t-set="categories" t-value="category.child_id" />
<t t-set="cur_level" t-value="cur_level+1" />
</t>
</t>
</template>
<template id="s_product_category_items">
<div class="container o_not_editable">
<div class="row">
<input
type="hidden"
name="object_count"
t-if="object"
t-att-value="len(object)"
/>
<div t-foreach="object" t-as="categories" class="p-2 col-12 col-md-3 col-lg-2 categ_container">
<div class="categ_scroll_wrapper px-2 h-100">
<div class="categ_scroll">
<t
t-call="website_snippet_product_category.s_product_category_items_recursive"
>
<t t-set="cur_level" t-value="1" />
</t>
</div>
</div>
</div>
</div>
</div>
</template>
<template id="s_product_category_options" inherit_id="website.snippet_options">
<xpath expr="." position="inside">
<div
data-js="js_product_category"
data-selector=".js_product_category"
data-template="website_snippet_product_category.s_product_category_items"
/>
</xpath>
</template>
</odoo>

View file

@ -0,0 +1,22 @@
<?xml version="1.0" encoding="utf-8" ?>
<odoo>
<data>
<record id="product_public_category_form_view" model="ir.ui.view">
<field name="name">public.category.form</field>
<field name="model">product.public.category</field>
<field
name="inherit_id"
ref="website_sale.product_public_category_form_view"
/>
<field name="arch" type="xml">
<field name="image_medium" position="before">
<div class="oe_button_box" name="button_box">
<button class="oe_stat_button" name="website_publish_button" type="object" icon="fa-globe">
<field name="website_published" widget="website_button"/>
</button>
</div>
</field>
</field>
</record>
</data>
</odoo>