Skip to content

Commit

Permalink
Merge pull request #256 from remytms/11.0-mig-website_sale_hide_empty…
Browse files Browse the repository at this point in the history
…_category

 [MIG] website_sale_hide_empty_category: Migration to 11.0
  • Loading branch information
pedrobaeza committed Nov 22, 2018
2 parents 98242a9 + ee7b507 commit d89f242
Show file tree
Hide file tree
Showing 7 changed files with 145 additions and 0 deletions.
56 changes: 56 additions & 0 deletions website_sale_hide_empty_category/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
.. 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

====================================
Website Sale - Hide Empty Categories
====================================

Removes any category links from the Shop which have no products associated
to them.

Usage
=====

Simply install the module and refresh your view. You will see the empty
categories disappear

.. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas
:alt: Try me on Runbot
:target: https://runbot.odoo-community.org/runbot/186/11.0

Bug Tracker
===========

Bugs are tracked on `GitHub Issues
<https://github.com/OCA/website/issues>`_. In case of trouble, please
check there if your issue has already been reported. If you spotted it first,
help us smash it by providing detailed and welcomed feedback.

Credits
=======

Images
------

* Odoo Community Association: `Icon <https://github.com/OCA/maintainer-tools/blob/master/template/module/static/description/icon.svg>`_.

Contributors
------------

* Ted Salmon <tsalmon@laslabs.com>

Maintainer
----------

.. image:: https://odoo-community.org/logo.png
:alt: Odoo Community Association
:target: https://odoo-community.org

This module is maintained by the OCA.

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.

To contribute to this module, please visit https://odoo-community.org.
4 changes: 4 additions & 0 deletions website_sale_hide_empty_category/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Copyright 2017 LasLabs Inc.
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl.html).

from . import models
19 changes: 19 additions & 0 deletions website_sale_hide_empty_category/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Copyright 2017 LasLabs Inc. <https://laslabs.com/>
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl.html).
{
"name": "Website Sale - Hide Empty Categories",
"summary": "Hide any Product Categories that are empty",
"version": "11.0.1.0.0",
"category": "Website",
"website": "https://github.com/OCA/e-commerce/",
"author": "LasLabs, Odoo Community Association (OCA)",
"license": "LGPL-3",
"application": False,
"installable": True,
"depends": [
"website_sale",
],
"data": [
"views/website_sale_templates.xml",
],
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * website_sale_hide_empty_category
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 11.0\n"
"Report-Msgid-Bugs-To: \n"
"Last-Translator: <>\n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: \n"

#. module: website_sale_hide_empty_category
#: model:ir.model.fields,field_description:website_sale_hide_empty_category.field_product_public_category_product_ids
msgid "Products"
msgstr ""

#. module: website_sale_hide_empty_category
#: model:ir.model,name:website_sale_hide_empty_category.model_product_public_category
msgid "Website Product Category"
msgstr ""

4 changes: 4 additions & 0 deletions website_sale_hide_empty_category/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Copyright 2017 LasLabs Inc.
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl.html).

from . import product_public_category
18 changes: 18 additions & 0 deletions website_sale_hide_empty_category/models/product_public_category.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Copyright 2017 LasLabs Inc.
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl.html).

from odoo import fields, models


class ProductPublicCategory(models.Model):
_inherit = 'product.public.category'

# This module relies on the M2M relation built from `product.template` to
# `product.public.category` named `public_categ_ids`
product_ids = fields.Many2many(
comodel_name='product.template',
string='Products',
relation='product_public_category_product_template_rel',
column1='product_public_category_id',
column2='product_template_id',
)
19 changes: 19 additions & 0 deletions website_sale_hide_empty_category/views/website_sale_templates.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright 2017 LasLabs Inc.
License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl.html).
-->

<odoo>

<template inherit_id="website_sale.categories_recursive"
id="hide_categories_recursive"
active="True"
customize_show="True"
name="Hide Empty Category list">
<xpath expr="//t[@t-name='website_sale.categories_recursive']"
position="attributes">
<attribute name="t-if">c.product_ids</attribute>
</xpath>
</template>

</odoo>

0 comments on commit d89f242

Please sign in to comment.