Skip to content

Commit

Permalink
[MIG] website_snippet_product_category: Migration to version 18.0
Browse files Browse the repository at this point in the history
TT54542
  • Loading branch information
pilarvargas-tecnativa committed Feb 12, 2025
1 parent 31bf525 commit 2453b13
Show file tree
Hide file tree
Showing 11 changed files with 71 additions and 39 deletions.
44 changes: 22 additions & 22 deletions website_snippet_product_category/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@ Website Snippet Product Category
: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/17.0/website_snippet_product_category
: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-17-0/e-commerce-17-0-website_snippet_product_category
: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=17.0
: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|
Expand Down Expand Up @@ -59,13 +59,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,18 +78,18 @@ 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
===========

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:%2017.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
`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.

Expand All @@ -104,13 +104,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 Expand Up @@ -138,6 +138,6 @@ 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/17.0/website_snippet_product_category>`_ project on GitHub.
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.
5 changes: 4 additions & 1 deletion website_snippet_product_category/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"name": "Website Snippet Product Category",
"category": "Website",
"summary": "Adds a new snippet to show e-commerce categories",
"version": "17.0.1.0.0",
"version": "18.0.1.0.0",
"license": "LGPL-3",
"website": "https://github.com/OCA/e-commerce",
"author": "Tecnativa, Odoo Community Association (OCA)",
Expand All @@ -21,6 +21,9 @@
"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"],
Expand Down
2 changes: 1 addition & 1 deletion website_snippet_product_category/demo/demo.xml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
<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.services" model="product.public.category">
<record id="website_sale.public_category_services" model="product.public.category">
<field name="published_in_product_category_snippet" eval="True" />
</record>
<record
Expand Down
2 changes: 1 addition & 1 deletion website_snippet_product_category/demo/pages.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
name="Snippet Product Category Test"
>
<t t-call="website.layout">
<div id="wrap" class="oe_structure oe_empty">
<div id="wrap">
<section class="s_product_category py-4">
<div class="js_product_category col-12" />
</section>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,7 @@ <h1 class="title">Website Snippet Product Category</h1>
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! 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><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/18.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-18-0/e-commerce-18-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=18.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><strong>Table of contents</strong></p>
<div class="contents local topic" id="contents">
Expand Down Expand Up @@ -443,7 +443,7 @@ <h1><a class="toc-backref" href="#toc-entry-5">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 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>
<a class="reference external" href="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**">feedback</a>.</p>
<p>Do not contact contributors directly about support or help with technical issues.</p>
</div>
<div class="section" id="credits">
Expand Down Expand Up @@ -482,7 +482,7 @@ <h2><a class="toc-backref" href="#toc-entry-10">Maintainers</a></h2>
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 image-reference" 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/17.0/website_snippet_product_category">OCA/e-commerce</a> project on GitHub.</p>
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/e-commerce/tree/18.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>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
/** @odoo-module **/

// Copyright 2020 Tecnativa - Alexandre Díaz
// Copyright 2025 Tecnativa - Pilar Vargas
// License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl).
import sAnimation from "@website/js/content/snippets.animation";
import {_t} from "@web/core/l10n/translation";
import {rpc} from "@web/core/network/rpc";

sAnimation.registry.js_product_category = sAnimation.Class.extend({
selector: ".js_product_category",
Expand All @@ -15,7 +14,6 @@ sAnimation.registry.js_product_category = sAnimation.Class.extend({
*/
init: function () {
this._super.apply(this, arguments);
this.rpc = this.bindService("rpc");
},

/**
Expand All @@ -29,7 +27,7 @@ sAnimation.registry.js_product_category = sAnimation.Class.extend({
"website_snippet_product_category.s_product_category_items";
// Prevent user edition
this.$target.attr("contenteditable", "false");
const def = this.rpc(
const def = rpc(
"/website_sale/render_product_category",
Object.assign({
template: template,
Expand All @@ -51,7 +49,6 @@ sAnimation.registry.js_product_category = sAnimation.Class.extend({
);
return;
}

_this.$target.html($object_html);
},
function () {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
/** @odoo-module **/

// Copyright 2020 Tecnativa - Alexandre Díaz

import options from "@web_editor/js/editor/snippets.options";
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/* Copyright 2025 Tecnativa - Pilar Vargas
* License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl.html). */
import {
clickOnSave,
clickOnSnippet,
insertSnippet,
registerWebsitePreviewTour,
} from "@website/js/tours/tour_utils";

registerWebsitePreviewTour(
"product_category",
{
url: "/",
edition: true,
},
() => [
...insertSnippet({id: "s_product_category", name: "Product Category"}),
...clickOnSnippet({id: "s_product_category", name: "Product Category"}),
...clickOnSave(),
]
);
5 changes: 1 addition & 4 deletions website_snippet_product_category/templates/snippets.xml
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
<?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"
>
<xpath expr="//snippets[@id='snippet_content']" 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"
Expand Down
1 change: 1 addition & 0 deletions website_snippet_product_category/tests/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import test_ui
15 changes: 15 additions & 0 deletions website_snippet_product_category/tests/test_ui.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Copyright 2025 Tecnativa - Pilar Vargas
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl.html).

import odoo.tests
from odoo.tests import tagged


@tagged("post_install", "-at_install")
class TestUi(odoo.tests.HttpCase):
def test_admin_tour_marginless_gallery(self):
self.start_tour(
self.env["website"].get_client_action_url("/"),
"product_category",
login="admin",
)

0 comments on commit 2453b13

Please sign in to comment.