From f6231e39575b42e02651dff880f4cf6bd5fd1797 Mon Sep 17 00:00:00 2001 From: snt Date: Wed, 4 May 2022 16:08:16 +0200 Subject: [PATCH] =?UTF-8?q?a=C3=B1adido=20addon=20para=20ordenar=20los=20p?= =?UTF-8?q?roductos=20en=20la=20web=20por=20su=20fecha=20de=20creaci=C3=B3?= =?UTF-8?q?n.=20depende=20de=20website=5Fsale=5Fproduct=5Fsort=20de=20OCA/?= =?UTF-8?q?e-commerce?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../__init__.py | 1 + .../__manifest__.py | 20 ++++++++++++++ .../models/__init__.py | 2 ++ .../models/website.py | 26 +++++++++++++++++++ 4 files changed, 49 insertions(+) create mode 100644 website_sale_product_sort_creation_date/__init__.py create mode 100644 website_sale_product_sort_creation_date/__manifest__.py create mode 100644 website_sale_product_sort_creation_date/models/__init__.py create mode 100644 website_sale_product_sort_creation_date/models/website.py diff --git a/website_sale_product_sort_creation_date/__init__.py b/website_sale_product_sort_creation_date/__init__.py new file mode 100644 index 0000000..0650744 --- /dev/null +++ b/website_sale_product_sort_creation_date/__init__.py @@ -0,0 +1 @@ +from . import models diff --git a/website_sale_product_sort_creation_date/__manifest__.py b/website_sale_product_sort_creation_date/__manifest__.py new file mode 100644 index 0000000..1a24024 --- /dev/null +++ b/website_sale_product_sort_creation_date/__manifest__.py @@ -0,0 +1,20 @@ +# Copyright 2021 Criptomart +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). +{ + 'name': 'Website Sale Product Sort Creation Date', + 'summary': 'Permite ordenar por la fecha de creación de los productos.', + 'version': '12.0.1.0.1', + 'development_status': 'Beta', + 'category': 'Website', + 'website': 'https://github.com/criptomart/obook', + 'author': 'Criptomart', + 'license': 'AGPL-3', + 'depends': [ + 'website', + 'website_sale_product_sort', + ], + 'data': [ + ], + 'application': False, + 'installable': True, +} diff --git a/website_sale_product_sort_creation_date/models/__init__.py b/website_sale_product_sort_creation_date/models/__init__.py new file mode 100644 index 0000000..40b75e0 --- /dev/null +++ b/website_sale_product_sort_creation_date/models/__init__.py @@ -0,0 +1,2 @@ +from . import website + diff --git a/website_sale_product_sort_creation_date/models/website.py b/website_sale_product_sort_creation_date/models/website.py new file mode 100644 index 0000000..cc705d6 --- /dev/null +++ b/website_sale_product_sort_creation_date/models/website.py @@ -0,0 +1,26 @@ +# Copyright 2021 Criptomart +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). +from odoo import _, api, fields, models + + +class Website(models.Model): + _inherit = "website" + + @api.model + def _get_product_sort_criterias(self): + return [ + ('website_sequence desc', _('Relevance')), + ('list_price desc', _('Catalog price: High to Low')), + ('list_price asc', _('Catalog price: Low to High')), + ('name asc', _('Name - A to Z')), + ('name desc', _('Name - Z to A')), + ('create_date desc', 'Novedades'), + ] + + default_product_sort_criteria = fields.Selection( + selection='_get_product_sort_criterias', + string="Sort products by", + help="Default criteria for sorting products in the shop", + default='create_date desc', + required=True, + )