Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[MIG] website_sale_product_attribute_value_filter_existing: Migration to v.12.0 #310

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
82 changes: 82 additions & 0 deletions website_sale_product_attribute_value_filter_existing/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
=====================================
Website Sale Attribute Value Existing
=====================================

.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! 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_sale_product_attribute_value_filter_existing
: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_sale_product_attribute_value_filter_existing
: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|

This module extends the functionality of website sale module to allow hide
product attributes values which exist but not used on any variants.

**Table of contents**

.. contents::
:local:

Usage
=====

* Go to Website Shop
* Active product attributes filter
* System only display the attribute values if used.

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_sale_product_attribute_value_filter_existing%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
~~~~~~~~~~~~

* Victor M.M. Torres <victor.martin@tecnativa.com>
* Sergio Teruel <sergio.teruel@tecnativa.com>

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.

This module is part of the `OCA/e-commerce <https://github.com/OCA/e-commerce/tree/12.0/website_sale_product_attribute_value_filter_existing>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl).
from . import controllers
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Copyright 2019 Tecnativa - Victor M.M. Torres
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl).
{
'name': 'Website Sale Attribute Value Existing',
'summary': 'Allow hide attributes values not used in variants',
'version': '12.0.1.0.0',
'development_status': 'Beta',
'category': 'Website',
'website': 'https://github.com/OCA/e-commerce',
'author': 'Tecnativa, Odoo Community Association (OCA)',
'license': 'LGPL-3',
'application': False,
'installable': True,
'depends': [
'website_sale',
],
'data': [
'views/assets.xml',
'views/templates.xml',
],
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl).
from . import main
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# Copyright 2019 Tecnativa - Sergio Teruel
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl).
from odoo.http import request
from odoo.addons.website_sale.controllers.main import WebsiteSale
from odoo import http


class ProductAttributeValues(WebsiteSale):

def _get_search_domain(self, search, category, attrib_values):
# Store used domain in context to be reused after
domain = super(ProductAttributeValues, self)._get_search_domain(
search, category, attrib_values)
new_context = dict(request.env.context, shop_search_domain=domain)
request.context = new_context
return domain

@http.route()
def shop(self, page=0, category=None, search='', ppg=False, **post):
res = super(ProductAttributeValues, self).shop(
page=page,
category=category,
search=search,
ppg=ppg,
**post)
domain = request.env.context.get('shop_search_domain', [])
# Load all products without limit for the filter check on
# attribute values
templates = request.env['product.template'].search(
domain, limit=False)
ProductTemplateAttributeLine = request.env[
'product.template.attribute.line']
attribute_values = ProductTemplateAttributeLine.search([
('product_tmpl_id', 'in', templates.ids),
])
res.qcontext['attr_values_used'] = attribute_values.mapped('value_ids')
return res
40 changes: 40 additions & 0 deletions website_sale_product_attribute_value_filter_existing/data/demo.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>

<record id="product_attribute_test_special_color" model="product.attribute">
<field name="website_published" eval="True"/>
<field name="name">Test Special Color</field>
</record>

<record id="product_attribute_value_color_red" model="product.attribute.value">
<field name="name">Test red</field>
<field name="attribute_id" ref="product_attribute_test_special_color"/>
</record>
<record id="product_attribute_value_color_green" model="product.attribute.value">
<field name="name">Test green</field>
<field name="attribute_id" ref="product_attribute_test_special_color"/>
</record>
<record id="product_attribute_value_color_blue" model="product.attribute.value">
<field name="name">Test blue</field>
<field name="attribute_id" ref="product_attribute_test_special_color"/>
</record>

<record id="product_attribute_line_test_color" model="product.attribute.line">
<field name="product_tmpl_id" ref="product.product_product_11_product_template"/>
<field name="attribute_id" ref="product_attribute_test_special_color"/>
<field name="value_ids" eval="[(6, 0, [ref('product_attribute_value_color_red'), ref('product_attribute_value_color_green')])]"/>
</record>
<record id="product.product_product_11_product_template" model="product.template">
<field name="attribute_line_ids" eval="[(4, ref('product_attribute_line_test_color'))]"/>
</record>

<record id="product_attribute_line_test_color_27" model="product.attribute.line">
<field name="product_tmpl_id" ref="product.product_product_27_product_template"/>
<field name="attribute_id" ref="product_attribute_test_special_color"/>
<field name="value_ids" eval="[(6, 0, [ref('product_attribute_value_color_red'), ref('product_attribute_value_color_blue')])]"/>
</record>
<record id="product.product_product_27_product_template" model="product.template">
<field name="attribute_line_ids" eval="[(4, ref('product_attribute_line_test_color_27'))]"/>
</record>

</odoo>
38 changes: 38 additions & 0 deletions website_sale_product_attribute_value_filter_existing/i18n/es.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * website_sale_product_attribute_value_filter_existing
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 11.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2019-05-15 08:17+0000\n"
"PO-Revision-Date: 2019-05-15 10:19+0200\n"
"Last-Translator: \n"
"Language-Team: \n"
"Language: es\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
"X-Generator: Poedit 2.0.6\n"

#. module: website_sale_product_attribute_value_filter_existing
#: model:product.attribute,name:website_sale_product_attribute_value_filter_existing.product_attribute_test_special_color
msgid "Test Special Color"
msgstr "Color especial de prueba"

#. module: website_sale_product_attribute_value_filter_existing
#: model:product.attribute.value,name:website_sale_product_attribute_value_filter_existing.product_attribute_value_color_blue
msgid "Test blue"
msgstr "azul"

#. module: website_sale_product_attribute_value_filter_existing
#: model:product.attribute.value,name:website_sale_product_attribute_value_filter_existing.product_attribute_value_color_green
msgid "Test green"
msgstr "verde"

#. module: website_sale_product_attribute_value_filter_existing
#: model:product.attribute.value,name:website_sale_product_attribute_value_filter_existing.product_attribute_value_color_red
msgid "Test red"
msgstr "rojo"
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * website_sale_product_attribute_value_filter_existing
#
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_product_attribute_value_filter_existing
#: model:product.attribute,name:website_sale_product_attribute_value_filter_existing.product_attribute_test_special_color
msgid "Test Special Color"
msgstr ""

#. module: website_sale_product_attribute_value_filter_existing
#: model:product.attribute.value,name:website_sale_product_attribute_value_filter_existing.product_attribute_value_color_blue
msgid "Test blue"
msgstr ""

#. module: website_sale_product_attribute_value_filter_existing
#: model:product.attribute.value,name:website_sale_product_attribute_value_filter_existing.product_attribute_value_color_green
msgid "Test green"
msgstr ""

#. module: website_sale_product_attribute_value_filter_existing
#: model:product.attribute.value,name:website_sale_product_attribute_value_filter_existing.product_attribute_value_color_red
msgid "Test red"
msgstr ""

Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
* Victor M.M. Torres <victor.martin@tecnativa.com>
* Sergio Teruel <sergio.teruel@tecnativa.com>
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
This module extends the functionality of website sale module to allow hide
product attributes values which exist but not used on any variants.
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
* Go to Website Shop
* Active product attributes filter
* System only display the attribute values if used.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading