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

[15.0] [MIG] website_sale_product_sort: MIgration to 15.0 #644

Merged
merged 18 commits into from
Dec 26, 2022
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
6 changes: 6 additions & 0 deletions setup/website_sale_product_sort/setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import setuptools

setuptools.setup(
setup_requires=['setuptools-odoo'],
odoo_addon=True,
)
114 changes: 114 additions & 0 deletions website_sale_product_sort/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
=========================
Website Sale Product Sort
=========================

.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

.. |badge1| image:: https://img.shields.io/badge/maturity-Production%2FStable-green.png
:target: https://odoo-community.org/page/development-status
:alt: Production/Stable
.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
:alt: License: AGPL-3
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fe--commerce-lightgray.png?logo=github
:target: https://github.com/OCA/e-commerce/tree/13.0/website_sale_product_sort
: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-13-0/e-commerce-13-0-website_sale_product_sort
: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/13.0
:alt: Try me on Runbot

|badge1| |badge2| |badge3| |badge4| |badge5|

This module allows to set a default sorting criteria for the e-commerce product
list.

It provides the standard criterias, but allows to extend the options via third
modules.

**Table of contents**

.. contents::
:local:

Configuration
=============

To configure this module, you need to:

#. Go to *Website > Configuration > Settings*
#. Select the website you want to configure.
#. In the *Product* section there's a *Sort Criteria* option that you
can set as the default one for the website selected.

To extend the module you can override the method providing sorting options like
this:

.. code-block:: python

@api.model
def _get_product_sort_criterias(self):
res = super()._get_product_sort_criterias()
return res.append(("default_code asc", _("Reference - A to Z")))

Usage
=====

After you've configured the default website settings:

#. Go to the configured website shop url.
#. The products will be sorted by default by the chosen option.

Known issues / Roadmap
======================

* Could be nice to have a related model to configure the sorting options without
the need of third modules.

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_sort%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.

Credits
=======

Authors
~~~~~~~

* Tecnativa

Contributors
~~~~~~~~~~~~

* `Tecnativa <https://www.tecnativa.com>`_:

* David Vidal
* Carlos Roca

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/13.0/website_sale_product_sort>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
2 changes: 2 additions & 0 deletions website_sale_product_sort/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
from . import controllers
from . import models
16 changes: 16 additions & 0 deletions website_sale_product_sort/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Copyright 2020 Tecnativa - David Vidal
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
{
"name": "Website Sale Product Sort",
"summary": "Allow to define default sort criteria for e-commerce",
"version": "15.0.1.0.0",
"development_status": "Production/Stable",
"category": "Website",
"website": "https://github.com/OCA/e-commerce",
"author": "Tecnativa, Odoo Community Association (OCA)",
"license": "AGPL-3",
"depends": ["website_sale"],
"data": ["views/website_sale_sort.xml", "views/res_config_settings_view.xml"],
"application": False,
"installable": True,
}
1 change: 1 addition & 0 deletions website_sale_product_sort/controllers/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import main
26 changes: 26 additions & 0 deletions website_sale_product_sort/controllers/main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Copyright 2020 Tecnativa - David Vidal
# Copyright 2021 Tecnativa - Pedro M. Baeza
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
from odoo.http import request, route

from odoo.addons.website_sale.controllers.main import WebsiteSale


class WebsiteSale(WebsiteSale):
def _get_search_order(self, post):
"""We can configure default sort criteria for every website"""
if post.get("order"):
return super()._get_search_order(post)
order = request.website.default_product_sort_criteria
return "is_published desc, %s, id desc" % order

@route()
def shop(self, page=0, category=None, search="", ppg=False, **post):
"""Transfer custom sort order to QWeb templates."""
response = super().shop(
page=page, category=category, search=search, ppg=ppg, **post
)
response.qcontext["order"] = (
post.get("order") or request.website.default_product_sort_criteria
)
return response
79 changes: 79 additions & 0 deletions website_sale_product_sort/i18n/ca.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * website_sale_product_sort
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 12.0\n"
"Report-Msgid-Bugs-To: \n"
"PO-Revision-Date: 2021-02-25 17:46+0000\n"
"Last-Translator: claudiagn <[email protected]>\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_sale_product_sort
#: code:addons/website_sale_product_sort/models/website.py:14
#, python-format
msgid "Catalog price: High to Low"
msgstr "Preu de catàleg: Alt a Baix"

#. module: website_sale_product_sort
#: code:addons/website_sale_product_sort/models/website.py:15
#, python-format
msgid "Catalog price: Low to High"
msgstr "Preu de catàleg: Baix a Alt"

#. module: website_sale_product_sort
#: model:ir.model,name:website_sale_product_sort.model_res_config_settings
msgid "Config Settings"
msgstr "Paràmetres de configuració"

#. module: website_sale_product_sort
#: model_terms:ir.ui.view,arch_db:website_sale_product_sort.res_config_settings_view_form
msgid "Default Sort Criteria"
msgstr "Criteris d'ordenació predeterminats"

#. module: website_sale_product_sort
#: model:ir.model.fields,help:website_sale_product_sort.field_res_config_settings__product_sort_criteria
#: model:ir.model.fields,help:website_sale_product_sort.field_website__default_product_sort_criteria
msgid "Default criteria for sorting products in the shop"
msgstr "Criteris predeterminats per ordenar els productes a la botiga"

#. module: website_sale_product_sort
#: code:addons/website_sale_product_sort/models/website.py:16
#, python-format
msgid "Name - A to Z"
msgstr "Nom - A a Z"

#. module: website_sale_product_sort
#: code:addons/website_sale_product_sort/models/website.py:17
#, python-format
msgid "Name - Z to A"
msgstr "Nom - Z a A"

#. module: website_sale_product_sort
#: code:addons/website_sale_product_sort/models/website.py:13
#, python-format
msgid "Relevance"
msgstr "Rellevància"

#. module: website_sale_product_sort
#: model_terms:ir.ui.view,arch_db:website_sale_product_sort.res_config_settings_view_form
msgid "Sort Criteria"
msgstr "Criteri d'ordenació"

#. module: website_sale_product_sort
#: model:ir.model.fields,field_description:website_sale_product_sort.field_res_config_settings__product_sort_criteria
#: model:ir.model.fields,field_description:website_sale_product_sort.field_website__default_product_sort_criteria
msgid "Sort products by"
msgstr "Ordenar productes per"

#. module: website_sale_product_sort
#: model:ir.model,name:website_sale_product_sort.model_website
msgid "Website"
msgstr "Web"
80 changes: 80 additions & 0 deletions website_sale_product_sort/i18n/es.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * website_sale_product_sort
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 12.0+e\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2020-05-13 10:59+0000\n"
"PO-Revision-Date: 2021-02-25 17:46+0000\n"
"Last-Translator: claudiagn <[email protected]>\n"
"Language-Team: \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 4.3.2\n"

#. module: website_sale_product_sort
#: code:addons/website_sale_product_sort/models/website.py:14
#, python-format
msgid "Catalog price: High to Low"
msgstr "Precio de catálogo: Mayor a Menor"

#. module: website_sale_product_sort
#: code:addons/website_sale_product_sort/models/website.py:15
#, python-format
msgid "Catalog price: Low to High"
msgstr "Precio de catálogo: Menor a Mayor"

#. module: website_sale_product_sort
#: model:ir.model,name:website_sale_product_sort.model_res_config_settings
msgid "Config Settings"
msgstr "Ajustes de Configuración"

#. module: website_sale_product_sort
#: model_terms:ir.ui.view,arch_db:website_sale_product_sort.res_config_settings_view_form
msgid "Default Sort Criteria"
msgstr "Criterio de ordenación por defecto"

#. module: website_sale_product_sort
#: model:ir.model.fields,help:website_sale_product_sort.field_res_config_settings__product_sort_criteria
#: model:ir.model.fields,help:website_sale_product_sort.field_website__default_product_sort_criteria
msgid "Default criteria for sorting products in the shop"
msgstr "Criterio por defecto para ordenar los productos en la tienda"

#. module: website_sale_product_sort
#: code:addons/website_sale_product_sort/models/website.py:16
#, python-format
msgid "Name - A to Z"
msgstr "Nombre: de la A a la Z"

#. module: website_sale_product_sort
#: code:addons/website_sale_product_sort/models/website.py:17
#, python-format
msgid "Name - Z to A"
msgstr "Nombre: de la Z a la A"

#. module: website_sale_product_sort
#: code:addons/website_sale_product_sort/models/website.py:13
#, python-format
msgid "Relevance"
msgstr "Relevancia"

#. module: website_sale_product_sort
#: model_terms:ir.ui.view,arch_db:website_sale_product_sort.res_config_settings_view_form
msgid "Sort Criteria"
msgstr "Criterio de ordenación"

#. module: website_sale_product_sort
#: model:ir.model.fields,field_description:website_sale_product_sort.field_res_config_settings__product_sort_criteria
#: model:ir.model.fields,field_description:website_sale_product_sort.field_website__default_product_sort_criteria
msgid "Sort products by"
msgstr "Ordernar productos por"

#. module: website_sale_product_sort
#: model:ir.model,name:website_sale_product_sort.model_website
msgid "Website"
msgstr "Web"
Loading