Skip to content

Commit

Permalink
[MIG] website_snippet_product_category: Migration to v13.0
Browse files Browse the repository at this point in the history
  • Loading branch information
CarlosRoca13 committed Apr 14, 2021
1 parent c500aae commit 9a3835c
Show file tree
Hide file tree
Showing 12 changed files with 54 additions and 49 deletions.
10 changes: 5 additions & 5 deletions website_snippet_product_category/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,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/12.0/website_snippet_product_category
:target: https://github.com/OCA/e-commerce/tree/13.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
:target: https://translation.odoo-community.org/projects/e-commerce-13-0/e-commerce-13-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
:target: https://runbot.odoo-community.org/runbot/113/13.0
:alt: Try me on Runbot

|badge1| |badge2| |badge3| |badge4| |badge5|
Expand Down Expand Up @@ -85,7 +85,7 @@ 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**>`_.
`feedback <https://github.com/OCA/e-commerce/issues/new?body=module:%20website_snippet_product_category%0Aversion:%2013.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 Down Expand Up @@ -131,6 +131,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/12.0/website_snippet_product_category>`_ project on GitHub.
This module is part of the `OCA/e-commerce <https://github.com/OCA/e-commerce/tree/13.0/website_snippet_product_category>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
4 changes: 2 additions & 2 deletions 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": "12.0.1.1.0",
"version": "13.0.1.0.0",
"license": "LGPL-3",
"website": "https://github.com/OCA/e-commerce",
"author": "Tecnativa, Odoo Community Association (OCA)",
Expand All @@ -14,7 +14,7 @@
"templates/snippets.xml",
"views/product_public_category.xml",
],
"demo": ["demo/demo.xml", "demo/pages.xml",],
"demo": ["demo/demo.xml", "demo/pages.xml"],
"maintainers": ["Tardo"],
"installable": True,
}
2 changes: 1 addition & 1 deletion website_snippet_product_category/controllers/website.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class Website(http.Controller):
)
def render_product_category(self, template, **kwargs):
categories = request.env["product.public.category"].search(
[("parent_id", "=", False), ("website_published", "=", True)]
[("parent_id", "=", False), ("is_published", "=", True)]
)
keep = QueryURL("/shop", category=0)
return request.website.viewref(template).render(
Expand Down
32 changes: 16 additions & 16 deletions website_snippet_product_category/demo/demo.xml
Original file line number Diff line number Diff line change
@@ -1,69 +1,69 @@
<?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" />
<field name="is_published" eval="True" />
</record>
<record id="website_sale.public_category_boxes" model="product.public.category">
<field name="website_published" eval="True" />
<field name="is_published" eval="True" />
<field
name="image_small"
name="image_128"
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" />
<field name="is_published" eval="True" />
</record>
<record id="website_sale.public_category_cabinets" model="product.public.category">
<field name="website_published" eval="True" />
<field name="is_published" eval="True" />
</record>
<record id="website_sale.public_category_bins" model="product.public.category">
<field name="website_published" eval="True" />
<field name="is_published" eval="True" />
</record>
<record id="website_sale.public_category_chairs" model="product.public.category">
<field name="website_published" eval="True" />
<field name="is_published" eval="True" />
</record>
<record id="website_sale.public_category_drawers" model="product.public.category">
<field name="website_published" eval="True" />
<field name="is_published" eval="True" />
</record>
<record id="website_sale.public_category_lamps" model="product.public.category">
<field name="website_published" eval="True" />
<field name="is_published" eval="True" />
</record>
<record
id="website_sale.public_category_multimedia"
model="product.public.category"
>
<field name="website_published" eval="True" />
<field name="is_published" eval="True" />
</record>
<record id="website_sale.services" model="product.public.category">
<field name="website_published" eval="True" />
<field name="is_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" />
<field name="is_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" />
<field name="is_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" />
<field name="is_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" />
<field name="is_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" />
<field name="is_published" eval="True" />
</record>
</odoo>
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 @@ -13,7 +13,7 @@
</t>
</template>
<record id="snippet_product_category_demo_page" model="website.page">
<field name="website_published">True</field>
<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>
Expand Down
1 change: 1 addition & 0 deletions website_snippet_product_category/readme/CONTRIBUTORS.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@

* Alexandre D. Díaz
* Pedro M. Baeza
* Carlos Roca
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<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/" />
<meta name="generator" content="Docutils: http://docutils.sourceforge.net/" />
<title>Website Snippet Product Category</title>
<style type="text/css">

Expand Down Expand Up @@ -367,7 +367,7 @@ <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><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/13.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-13-0/e-commerce-13-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/13.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">
Expand Down Expand Up @@ -438,7 +438,7 @@ <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>
<a class="reference external" href="https://github.com/OCA/e-commerce/issues/new?body=module:%20website_snippet_product_category%0Aversion:%2013.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 @@ -472,7 +472,7 @@ <h2><a class="toc-backref" href="#id10">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" 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>This module is part of the <a class="reference external" href="https://github.com/OCA/e-commerce/tree/13.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
25 changes: 13 additions & 12 deletions website_snippet_product_category/static/src/js/frontend.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,37 +3,38 @@
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");
const core = require("web.core");
const sAnimation = require("website.content.snippets.animation");

var _t = core._t;
const _t = core._t;

sAnimation.registry.js_product_category = sAnimation.Class.extend({
selector: ".js_product_category",
disabledInEditableMode: false,

/**
* Asynchronous server side template rendering
* @override
*/
start: function() {
var self = this;
var template =
const _this = this;
const 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({
const 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();
const $object_html = $(object_html);
const count = $object_html.find("input[name='object_count']").val();
if (!count) {
self.$target.append(
_this.$target.append(
$("<div/>").append(
$("<div/>", {
class:
Expand All @@ -50,11 +51,11 @@ odoo.define("website_snippet_product_category.s_product_category", function(requ
return;
}

self.$target.html($object_html);
_this.$target.html($object_html);
},
function() {
if (self.editableMode) {
self.$target.append(
if (_this.editableMode) {
_this.$target.append(
$("<p/>", {
class: "text-danger",
text: _t(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
// 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) {
odoo.define("website_snippet_product_category.snippet_options", function(require) {
"use strict";

var options = require("web_editor.snippets.options");
const options = require("web_editor.snippets.options");

options.registry.js_product_category = options.Class.extend({
/**
Expand Down
2 changes: 1 addition & 1 deletion website_snippet_product_category/templates/assets.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
/>
</xpath>
</template>
<template id="assets_editor" inherit_id="web_editor.assets_editor">
<template id="assets_editor" inherit_id="website.assets_editor">
<xpath expr="script[last()]" position="after">
<script
type="text/javascript"
Expand Down
6 changes: 3 additions & 3 deletions website_snippet_product_category/templates/snippets.xml
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,12 @@
<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"
t-if="category.website_published"
t-if="category.is_published"
>
<div class="d-flex d-flex-row">
<div
t-if="category.image_small"
t-field="category.image_small"
t-if="category.image_128"
t-field="category.image_128"
class="categ_img pr-1"
t-options="{'widget': 'image','resize': '24x24' }"
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,18 @@
ref="website_sale.product_public_category_form_view"
/>
<field name="arch" type="xml">
<field name="image_medium" position="before">
<field name="image_1920" 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" />
<field
name="is_published"
widget="website_publish_button"
/>
</button>
</div>
</field>
Expand Down

0 comments on commit 9a3835c

Please sign in to comment.