diff --git a/website_sale_menu_partner_top_selling/README.rst b/website_sale_menu_partner_top_selling/README.rst new file mode 100644 index 0000000000..84140edaa1 --- /dev/null +++ b/website_sale_menu_partner_top_selling/README.rst @@ -0,0 +1,118 @@ +.. image:: https://odoo-community.org/readme-banner-image + :target: https://odoo-community.org/get-involved?utm_source=readme + :alt: Odoo Community Association + +===================================== +Website Sale Menu Partner Top Selling +===================================== + +.. + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! source digest: sha256:551f110e4312267011f5510e441abdf47f84484bccdc8b1a68a8932202220d5c + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |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/license-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/19.0/website_sale_menu_partner_top_selling + :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-19-0/e-commerce-19-0-website_sale_menu_partner_top_selling + :alt: Translate me on Weblate +.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png + :target: https://runboat.odoo-community.org/builds?repo=OCA/e-commerce&target_branch=19.0 + :alt: Try me on Runboat + +|badge1| |badge2| |badge3| |badge4| |badge5| + +This module allows you to display the products purchased regularly by a +user and his company in the online shop. + +**Table of contents** + +.. contents:: + :local: + +Configuration +============= + +The module allows you to configure the number of products to be +displayed by means of a configuration parameter. + +Limit settings: + +Go to Settings > Website > Products and adjust the value in the +corresponding field to set the maximum number of products to be +displayed on the regular products page. The category panel must also be +active in /shop. + +Usage +===== + +Regular products can be viewed by accessing the URL +/shop/my_regular_products on the website. + +This URL can be accessed from */shop* by clicking on *My regular +products* in the category menu. + +The page will display the products regularly purchased by the user's +company's customers, sorted by the number of units sold in descending +order. + +Bug Tracker +=========== + +Bugs are tracked on `GitHub Issues `_. +In case of trouble, please check there if your issue has already been reported. +If you spotted it first, help us to smash it by providing a detailed and welcomed +`feedback `_. + +Do not contact contributors directly about support or help with technical issues. + +Credits +======= + +Authors +------- + +* Tecnativa + +Contributors +------------ + +- `Tecnativa `__ + + - Pilar Vargas + - Cristina Hidalgo + +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. + +.. |maintainer-pilarvargas-tecnativa| image:: https://github.com/pilarvargas-tecnativa.png?size=40px + :target: https://github.com/pilarvargas-tecnativa + :alt: pilarvargas-tecnativa + +Current `maintainer `__: + +|maintainer-pilarvargas-tecnativa| + +This module is part of the `OCA/e-commerce `_ project on GitHub. + +You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/website_sale_menu_partner_top_selling/__init__.py b/website_sale_menu_partner_top_selling/__init__.py new file mode 100644 index 0000000000..91c5580fed --- /dev/null +++ b/website_sale_menu_partner_top_selling/__init__.py @@ -0,0 +1,2 @@ +from . import controllers +from . import models diff --git a/website_sale_menu_partner_top_selling/__manifest__.py b/website_sale_menu_partner_top_selling/__manifest__.py new file mode 100644 index 0000000000..8b0c902ed6 --- /dev/null +++ b/website_sale_menu_partner_top_selling/__manifest__.py @@ -0,0 +1,21 @@ +# Copyright 2024 Tecnativa - Pilar Vargas +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). +{ + "name": "Website Sale Menu Partner Top Selling", + "summary": "Displays the user's regular products in the e-commerce.", + "version": "19.0.1.0.0", + "category": "Website", + "website": "https://github.com/OCA/e-commerce", + "author": "Tecnativa, Odoo Community Association (OCA)", + "license": "AGPL-3", + "application": False, + "installable": True, + "depends": ["website_sale"], + "data": ["views/res_config_settings_views.xml", "views/templates.xml"], + "assets": { + "web.assets_tests": [ + "website_sale_menu_partner_top_selling/static/src/js/tours/*.esm.js" + ], + }, + "maintainers": ["pilarvargas-tecnativa"], +} diff --git a/website_sale_menu_partner_top_selling/controllers/__init__.py b/website_sale_menu_partner_top_selling/controllers/__init__.py new file mode 100644 index 0000000000..12a7e529b6 --- /dev/null +++ b/website_sale_menu_partner_top_selling/controllers/__init__.py @@ -0,0 +1 @@ +from . import main diff --git a/website_sale_menu_partner_top_selling/controllers/main.py b/website_sale_menu_partner_top_selling/controllers/main.py new file mode 100644 index 0000000000..7e7f8a31b6 --- /dev/null +++ b/website_sale_menu_partner_top_selling/controllers/main.py @@ -0,0 +1,113 @@ +from odoo import http +from odoo.http import request +from odoo.tools import lazy + +from odoo.addons.website_sale.controllers.main import TableCompute, WebsiteSale + + +class WebsiteSale(WebsiteSale): + @http.route( + ["/shop/my_regular_products", "/shop/my_regular_products/page/"], + type="http", + auth="public", + website=True, + ) + def user_regular_products(self, page=0, ppg=False, **kwargs): + if request.env.user.has_group("base.group_public"): + return request.redirect("/web/login") + website = request.env["website"].get_current_website() + param_limit = int( + request.env["ir.config_parameter"] + .sudo() + .get_param("website_sale_menu_partner_top_selling.limit", 10) + ) + # Get best-selling products from the user + partner = request.env.user.partner_id + company_partner = partner.commercial_partner_id or partner + product_data = ( + request.env["sale.order.line"] + .sudo() + ._read_group( + domain=[ + ( + "order_id.partner_id.commercial_partner_id", + "=", + company_partner.id, + ), + ("order_id.state", "in", ["sale", "done"]), + ("product_id.product_tmpl_id.website_published", "=", True), + ( + "product_id.product_tmpl_id.website_id", + "in", + [request.website.id, False], + ), + ( + "product_id.product_tmpl_id.company_id", + "in", + [request.website.company_id.id, False], + ), + ], + groupby=["product_id"], + aggregates=["product_uom_qty:sum"], + ) + ) + # Sum quantities per template (a template may have several variants sold) + template_quantities = {} + for product, qty in product_data: + template = product.product_tmpl_id + template_quantities[template] = template_quantities.get(template, 0) + qty + # Sort the templates by total quantity sold and limit + sorted_templates = sorted( + template_quantities, key=template_quantities.get, reverse=True + ) + templates = request.env["product.template"].concat( + *sorted_templates[:param_limit] + ) + # Pagination + ppg = ppg or 20 + total_products = len(templates) + page_count = (total_products + ppg - 1) // ppg + page = max(0, min(page, page_count - 1)) + offset = page * ppg + products_on_page = templates[offset : offset + ppg] + pager = request.website.pager( + url="/shop/my_regular_products", + total=total_products, + page=page + 1, + step=ppg, + scope=5, + url_args=kwargs, + ) + products_prices = lazy(lambda: products_on_page._get_sales_prices(website)) + # Map each product to its variant, like WebsiteSale.shop() does, since our + # own product set differs from the one shop() computed for itself. + variants = ( + request.env["product.product"] + .sudo() + .browse( + product._get_first_possible_variant_id() for product in products_on_page + ) + ) + variants.fetch() + product_variants = dict(zip(products_on_page, variants, strict=False)) + # Shop context for the view + shop_context = self.shop(page=page, **kwargs) + shop_context.qcontext.update( + { + "pager": pager, + "products": products_on_page, + "search_product": products_on_page, + "search_count": total_products, + "product_variants": product_variants, + "bins": lazy( + lambda: TableCompute().process( + products_on_page, ppg, website.shop_ppr or 4 + ) + ), + "products_prices": products_prices, + "get_product_prices": lambda product: lazy( + lambda: products_prices[product.id] + ), + } + ) + return request.render("website_sale.products", shop_context.qcontext) diff --git a/website_sale_menu_partner_top_selling/i18n/ca.po b/website_sale_menu_partner_top_selling/i18n/ca.po new file mode 100644 index 0000000000..401db3074c --- /dev/null +++ b/website_sale_menu_partner_top_selling/i18n/ca.po @@ -0,0 +1,43 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * website_sale_menu_partner_top_selling +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 15.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2025-01-09 12:22+0000\n" +"PO-Revision-Date: 2026-05-05 15:14+0000\n" +"Last-Translator: Anonymous \n" +"Language-Team: \n" +"Language: ca\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: Weblate 5.15.2\n" + +#. module: website_sale_menu_partner_top_selling +#: model:ir.model,name:website_sale_menu_partner_top_selling.model_res_config_settings +msgid "Config Settings" +msgstr "Ajustos de configuració" + +#. module: website_sale_menu_partner_top_selling +#: model_terms:ir.ui.view,arch_db:website_sale_menu_partner_top_selling.view_stock_configuration +msgid "" +"Define the number of regular products you want to display in the e-commerce " +"catalog." +msgstr "" +"Defineix el nombre de productes regulars que vols mostrar al catàleg de " +"comerç electrònic." + +#. module: website_sale_menu_partner_top_selling +#: model_terms:ir.ui.view,arch_db:website_sale_menu_partner_top_selling.products_categories_top_user_selling +msgid "My Regular Products" +msgstr "Els meus productes habituals" + +#. module: website_sale_menu_partner_top_selling +#: model:ir.model.fields,field_description:website_sale_menu_partner_top_selling.field_res_config_settings__regular_products_limit +#: model_terms:ir.ui.view,arch_db:website_sale_menu_partner_top_selling.view_stock_configuration +msgid "Regular Products Limit" +msgstr "Límit de productes habituals" diff --git a/website_sale_menu_partner_top_selling/i18n/es.po b/website_sale_menu_partner_top_selling/i18n/es.po new file mode 100644 index 0000000000..3d40c8c075 --- /dev/null +++ b/website_sale_menu_partner_top_selling/i18n/es.po @@ -0,0 +1,43 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * website_sale_menu_partner_top_selling +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 15.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2025-01-09 12:22+0000\n" +"PO-Revision-Date: 2026-05-05 15:14+0000\n" +"Last-Translator: Anonymous \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: Weblate 5.15.2\n" + +#. module: website_sale_menu_partner_top_selling +#: model:ir.model,name:website_sale_menu_partner_top_selling.model_res_config_settings +msgid "Config Settings" +msgstr "Opciones de configuración" + +#. module: website_sale_menu_partner_top_selling +#: model_terms:ir.ui.view,arch_db:website_sale_menu_partner_top_selling.view_stock_configuration +msgid "" +"Define the number of regular products you want to display in the e-commerce " +"catalog." +msgstr "" +"Defina el número de productos habituales que desea mostrar en el catálogo de " +"productos de comercio electrónico." + +#. module: website_sale_menu_partner_top_selling +#: model_terms:ir.ui.view,arch_db:website_sale_menu_partner_top_selling.products_categories_top_user_selling +msgid "My Regular Products" +msgstr "Mis productos habituales" + +#. module: website_sale_menu_partner_top_selling +#: model:ir.model.fields,field_description:website_sale_menu_partner_top_selling.field_res_config_settings__regular_products_limit +#: model_terms:ir.ui.view,arch_db:website_sale_menu_partner_top_selling.view_stock_configuration +msgid "Regular Products Limit" +msgstr "Límite de productos habituales" diff --git a/website_sale_menu_partner_top_selling/i18n/it.po b/website_sale_menu_partner_top_selling/i18n/it.po new file mode 100644 index 0000000000..cd87024030 --- /dev/null +++ b/website_sale_menu_partner_top_selling/i18n/it.po @@ -0,0 +1,42 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * website_sale_menu_partner_top_selling +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 17.0\n" +"Report-Msgid-Bugs-To: \n" +"PO-Revision-Date: 2026-05-05 15:14+0000\n" +"Last-Translator: mymage \n" +"Language-Team: none\n" +"Language: it\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 5.15.2\n" + +#. module: website_sale_menu_partner_top_selling +#: model:ir.model,name:website_sale_menu_partner_top_selling.model_res_config_settings +msgid "Config Settings" +msgstr "Impostazioni configurazione" + +#. module: website_sale_menu_partner_top_selling +#: model_terms:ir.ui.view,arch_db:website_sale_menu_partner_top_selling.view_stock_configuration +msgid "" +"Define the number of regular products you want to display in the e-commerce " +"catalog." +msgstr "" +"Definire il numero dei prodotti regolari che si vuole visualizzare nel " +"catalogo di e-commerce." + +#. module: website_sale_menu_partner_top_selling +#: model_terms:ir.ui.view,arch_db:website_sale_menu_partner_top_selling.products_categories_top_user_selling +msgid "My Regular Products" +msgstr "I miei prodotti regolari" + +#. module: website_sale_menu_partner_top_selling +#: model:ir.model.fields,field_description:website_sale_menu_partner_top_selling.field_res_config_settings__regular_products_limit +#: model_terms:ir.ui.view,arch_db:website_sale_menu_partner_top_selling.view_stock_configuration +msgid "Regular Products Limit" +msgstr "Limite prodotti regolari" diff --git a/website_sale_menu_partner_top_selling/i18n/website_sale_menu_partner_top_selling.pot b/website_sale_menu_partner_top_selling/i18n/website_sale_menu_partner_top_selling.pot new file mode 100644 index 0000000000..d726c6d735 --- /dev/null +++ b/website_sale_menu_partner_top_selling/i18n/website_sale_menu_partner_top_selling.pot @@ -0,0 +1,37 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * website_sale_menu_partner_top_selling +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 17.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_menu_partner_top_selling +#: model:ir.model,name:website_sale_menu_partner_top_selling.model_res_config_settings +msgid "Config Settings" +msgstr "" + +#. module: website_sale_menu_partner_top_selling +#: model_terms:ir.ui.view,arch_db:website_sale_menu_partner_top_selling.view_stock_configuration +msgid "" +"Define the number of regular products you want to display in the e-commerce " +"catalog." +msgstr "" + +#. module: website_sale_menu_partner_top_selling +#: model_terms:ir.ui.view,arch_db:website_sale_menu_partner_top_selling.products_categories_top_user_selling +msgid "My Regular Products" +msgstr "" + +#. module: website_sale_menu_partner_top_selling +#: model:ir.model.fields,field_description:website_sale_menu_partner_top_selling.field_res_config_settings__regular_products_limit +#: model_terms:ir.ui.view,arch_db:website_sale_menu_partner_top_selling.view_stock_configuration +msgid "Regular Products Limit" +msgstr "" diff --git a/website_sale_menu_partner_top_selling/models/__init__.py b/website_sale_menu_partner_top_selling/models/__init__.py new file mode 100644 index 0000000000..0deb68c468 --- /dev/null +++ b/website_sale_menu_partner_top_selling/models/__init__.py @@ -0,0 +1 @@ +from . import res_config_settings diff --git a/website_sale_menu_partner_top_selling/models/res_config_settings.py b/website_sale_menu_partner_top_selling/models/res_config_settings.py new file mode 100644 index 0000000000..5a8356f8e2 --- /dev/null +++ b/website_sale_menu_partner_top_selling/models/res_config_settings.py @@ -0,0 +1,12 @@ +# Copyright 2024 Tecnativa - Pilar Vargas +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +from odoo import fields, models + + +class ResConfigSettings(models.TransientModel): + _inherit = "res.config.settings" + + regular_products_limit = fields.Integer( + default=10, config_parameter="website_sale_menu_partner_top_selling.limit" + ) diff --git a/website_sale_menu_partner_top_selling/pyproject.toml b/website_sale_menu_partner_top_selling/pyproject.toml new file mode 100644 index 0000000000..4231d0cccb --- /dev/null +++ b/website_sale_menu_partner_top_selling/pyproject.toml @@ -0,0 +1,3 @@ +[build-system] +requires = ["whool"] +build-backend = "whool.buildapi" diff --git a/website_sale_menu_partner_top_selling/readme/CONFIGURE.md b/website_sale_menu_partner_top_selling/readme/CONFIGURE.md new file mode 100644 index 0000000000..b93720c43f --- /dev/null +++ b/website_sale_menu_partner_top_selling/readme/CONFIGURE.md @@ -0,0 +1,9 @@ +The module allows you to configure the number of products to be +displayed by means of a configuration parameter. + +Limit settings: + +Go to Settings \> Website \> Products and adjust the value in the +corresponding field to set the maximum number of products to be +displayed on the regular products page. The category panel must also be +active in /shop. diff --git a/website_sale_menu_partner_top_selling/readme/CONTRIBUTORS.md b/website_sale_menu_partner_top_selling/readme/CONTRIBUTORS.md new file mode 100644 index 0000000000..0033bcca52 --- /dev/null +++ b/website_sale_menu_partner_top_selling/readme/CONTRIBUTORS.md @@ -0,0 +1,3 @@ +- [Tecnativa](https://www.tecnativa.com) + - Pilar Vargas + - Cristina Hidalgo diff --git a/website_sale_menu_partner_top_selling/readme/DESCRIPTION.md b/website_sale_menu_partner_top_selling/readme/DESCRIPTION.md new file mode 100644 index 0000000000..061a1730d8 --- /dev/null +++ b/website_sale_menu_partner_top_selling/readme/DESCRIPTION.md @@ -0,0 +1,2 @@ +This module allows you to display the products purchased regularly by a +user and his company in the online shop. diff --git a/website_sale_menu_partner_top_selling/readme/USAGE.md b/website_sale_menu_partner_top_selling/readme/USAGE.md new file mode 100644 index 0000000000..fc778183cd --- /dev/null +++ b/website_sale_menu_partner_top_selling/readme/USAGE.md @@ -0,0 +1,9 @@ +Regular products can be viewed by accessing the URL +/shop/my_regular_products on the website. + +This URL can be accessed from */shop* by clicking on *My regular +products* in the category menu. + +The page will display the products regularly purchased by the user's +company's customers, sorted by the number of units sold in descending +order. diff --git a/website_sale_menu_partner_top_selling/static/description/icon.png b/website_sale_menu_partner_top_selling/static/description/icon.png new file mode 100644 index 0000000000..3a0328b516 Binary files /dev/null and b/website_sale_menu_partner_top_selling/static/description/icon.png differ diff --git a/website_sale_menu_partner_top_selling/static/description/index.html b/website_sale_menu_partner_top_selling/static/description/index.html new file mode 100644 index 0000000000..04e90f12ad --- /dev/null +++ b/website_sale_menu_partner_top_selling/static/description/index.html @@ -0,0 +1,458 @@ + + + + + +Website Sale Menu Partner Top Selling + + + +
+ + + +Odoo Community Association + +
+

Website Sale Menu Partner Top Selling

+ +

Beta License: AGPL-3 OCA/e-commerce Translate me on Weblate Try me on Runboat

+

This module allows you to display the products purchased regularly by a +user and his company in the online shop.

+

Table of contents

+ +
+

Configuration

+

The module allows you to configure the number of products to be +displayed by means of a configuration parameter.

+

Limit settings:

+

Go to Settings > Website > Products and adjust the value in the +corresponding field to set the maximum number of products to be +displayed on the regular products page. The category panel must also be +active in /shop.

+
+
+

Usage

+

Regular products can be viewed by accessing the URL +/shop/my_regular_products on the website.

+

This URL can be accessed from /shop by clicking on My regular +products in the category menu.

+

The page will display the products regularly purchased by the user’s +company’s customers, sorted by the number of units sold in descending +order.

+
+
+

Bug Tracker

+

Bugs are tracked on GitHub Issues. +In case of trouble, please check there if your issue has already been reported. +If you spotted it first, help us to smash it by providing a detailed and welcomed +feedback.

+

Do not contact contributors directly about support or help with technical issues.

+
+
+

Credits

+
+

Authors

+
    +
  • Tecnativa
  • +
+
+
+

Contributors

+
    +
  • Tecnativa
      +
    • Pilar Vargas
    • +
    • Cristina Hidalgo
    • +
    +
  • +
+
+
+

Maintainers

+

This module is maintained by the OCA.

+ +Odoo Community Association + +

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.

+

Current maintainer:

+

pilarvargas-tecnativa

+

This module is part of the OCA/e-commerce project on GitHub.

+

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

+
+
+
+
+ + diff --git a/website_sale_menu_partner_top_selling/static/src/js/tours/website_sale_menu_top_user_selling_tour.esm.js b/website_sale_menu_partner_top_selling/static/src/js/tours/website_sale_menu_top_user_selling_tour.esm.js new file mode 100644 index 0000000000..b100061a35 --- /dev/null +++ b/website_sale_menu_partner_top_selling/static/src/js/tours/website_sale_menu_top_user_selling_tour.esm.js @@ -0,0 +1,18 @@ +/* Copyright 2024 Pilar Vargas + * License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). */ +import {registry} from "@web/core/registry"; + +registry.category("web_tour.tours").add("website_sale_menu_partner_top_selling", { + url: "/shop", + steps: () => [ + { + trigger: "#products_grid_before a:contains('My Regular Products')", + run: "click", + expectUnloadPage: true, + }, + { + trigger: + "#products_grid:has(a:contains('Product 5')):has(a:contains('Product 3')):not(:has(a:contains('Product 1'))):not(:has(a:contains('Product 2'))):not(:has(a:contains('Product 4')))", + }, + ], +}); diff --git a/website_sale_menu_partner_top_selling/tests/__init__.py b/website_sale_menu_partner_top_selling/tests/__init__.py new file mode 100644 index 0000000000..6dab214ac8 --- /dev/null +++ b/website_sale_menu_partner_top_selling/tests/__init__.py @@ -0,0 +1 @@ +from . import test_ui diff --git a/website_sale_menu_partner_top_selling/tests/test_ui.py b/website_sale_menu_partner_top_selling/tests/test_ui.py new file mode 100644 index 0000000000..719e3798a3 --- /dev/null +++ b/website_sale_menu_partner_top_selling/tests/test_ui.py @@ -0,0 +1,68 @@ +# Copyright 2024 Tecnativa - Pilar Vargas +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +from odoo.tests.common import HttpCase, tagged + +from odoo.addons.base.tests.common import DISABLED_MAIL_CONTEXT + + +@tagged("post_install", "-at_install") +class TestUi(HttpCase): + @classmethod + def setUpClass(cls): + super().setUpClass() + cls.env = cls.env(context=dict(cls.env.context, **DISABLED_MAIL_CONTEXT)) + cls.env.ref("website_sale.products_categories").active = True + cls.env["ir.config_parameter"].sudo().set_param( + "website_sale_menu_partner_top_selling.limit", 2 + ) + cls.admin_user = cls.env.ref("base.user_admin") + cls.partner = cls.admin_user.partner_id + cls.products = [] + for i in range(1, 6): + product = cls.env["product.product"].create( + { + "name": f"Product {i}", + "list_price": 10.0 * i, + } + ) + product.product_tmpl_id.website_published = True + cls.products.append(product) + cls.sale_order = cls.env["sale.order"].create( + { + "partner_id": cls.partner.id, + } + ) + quantities = [50, 30, 70, 10, 90] + for product, qty in zip(cls.products, quantities, strict=True): + cls.env["sale.order.line"].create( + { + "order_id": cls.sale_order.id, + "product_id": product.id, + "product_uom_qty": qty, + "price_unit": product.list_price, + } + ) + cls.sale_order.action_confirm() + # Unconfirmed order, no products to be counted + cls.sale_order_2 = cls.env["sale.order"].create( + { + "partner_id": cls.partner.id, + } + ) + cls.env["sale.order.line"].create( + { + "order_id": cls.sale_order_2.id, + "product_id": cls.products[0].id, + "product_uom_qty": 1000, + "price_unit": cls.products[0].list_price, + } + ) + + def test_ui(self): + """Test frontend tour.""" + self.start_tour( + "/shop", + "website_sale_menu_partner_top_selling", + login="admin", + ) diff --git a/website_sale_menu_partner_top_selling/views/res_config_settings_views.xml b/website_sale_menu_partner_top_selling/views/res_config_settings_views.xml new file mode 100644 index 0000000000..2d5730cee2 --- /dev/null +++ b/website_sale_menu_partner_top_selling/views/res_config_settings_views.xml @@ -0,0 +1,20 @@ + + + + + res.config.settings + + + + + + + + + + diff --git a/website_sale_menu_partner_top_selling/views/templates.xml b/website_sale_menu_partner_top_selling/views/templates.xml new file mode 100644 index 0000000000..df4fbbf1c0 --- /dev/null +++ b/website_sale_menu_partner_top_selling/views/templates.xml @@ -0,0 +1,54 @@ + + + + + +