From f936f6f891efe86f6a6e298edf8193ffca02ee30 Mon Sep 17 00:00:00 2001 From: Alexis Lopez Date: Fri, 6 Dec 2024 16:01:27 -0300 Subject: [PATCH] [MIG] website_sale_product_pack: Migration to 18.0 --- website_sale_product_pack/README.rst | 44 +++++++++---------- website_sale_product_pack/__manifest__.py | 2 +- .../controllers/__init__.py | 2 - website_sale_product_pack/controllers/main.py | 27 ------------ .../controllers/variant.py | 25 ----------- .../models/product_template.py | 33 ++++++++++++++ website_sale_product_pack/models/website.py | 12 ----- .../static/description/index.html | 10 ++--- .../tours/website_sale_product_pack_tour.js | 15 ++++--- website_sale_product_pack/views/templates.xml | 4 +- 10 files changed, 72 insertions(+), 102 deletions(-) delete mode 100644 website_sale_product_pack/controllers/__init__.py delete mode 100644 website_sale_product_pack/controllers/main.py delete mode 100644 website_sale_product_pack/controllers/variant.py diff --git a/website_sale_product_pack/README.rst b/website_sale_product_pack/README.rst index e76386a7b..cbf60ec4d 100644 --- a/website_sale_product_pack/README.rst +++ b/website_sale_product_pack/README.rst @@ -17,29 +17,29 @@ Website Sale Product Pack :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html :alt: License: AGPL-3 .. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fproduct--pack-lightgray.png?logo=github - :target: https://github.com/OCA/product-pack/tree/17.0/website_sale_product_pack + :target: https://github.com/OCA/product-pack/tree/18.0/website_sale_product_pack :alt: OCA/product-pack .. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png - :target: https://translation.odoo-community.org/projects/product-pack-17-0/product-pack-17-0-website_sale_product_pack + :target: https://translation.odoo-community.org/projects/product-pack-18-0/product-pack-18-0-website_sale_product_pack :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/product-pack&target_branch=17.0 + :target: https://runboat.odoo-community.org/builds?repo=OCA/product-pack&target_branch=18.0 :alt: Try me on Runboat |badge1| |badge2| |badge3| |badge4| |badge5| This module introduces compatibility of product packs with e-commerce: -- In the cart summary, the components aren't editable and are shown - hanging from the main pack reference. -- When we remove a pack from the cart, their components are removed as - well. -- The cart popup summary only shows the main pack line and discards the - sublines in the units count. -- The cart summary shows the component lines hanging from the main one - as well. -- It's ensured the the prices are shown correctly for the whole pack - and that they're correctly summarized depending on the pack type. +- In the cart summary, the components aren't editable and are shown + hanging from the main pack reference. +- When we remove a pack from the cart, their components are removed as + well. +- The cart popup summary only shows the main pack line and discards the + sublines in the units count. +- The cart summary shows the component lines hanging from the main one + as well. +- It's ensured the the prices are shown correctly for the whole pack and + that they're correctly summarized depending on the pack type. **Table of contents** @@ -56,9 +56,9 @@ as if you do it in the backend. Known issues / Roadmap ====================== -- Improve pack cart display. -- When we have subpacks (a pack inside a pack) we should improve - visually how it's shown in the cart. +- Improve pack cart display. +- When we have subpacks (a pack inside a pack) we should improve + visually how it's shown in the cart. Bug Tracker =========== @@ -66,7 +66,7 @@ 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 `_. +`feedback `_. Do not contact contributors directly about support or help with technical issues. @@ -81,13 +81,13 @@ Authors Contributors ------------ -- `Tecnativa `__: +- `Tecnativa `__: - - David Vidal + - David Vidal -- `ADHOC SA `__: +- `ADHOC SA `__: - - Nicolas Mac Rouillon + - Nicolas Mac Rouillon Maintainers ----------- @@ -102,6 +102,6 @@ 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/product-pack `_ project on GitHub. +This module is part of the `OCA/product-pack `_ project on GitHub. You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/website_sale_product_pack/__manifest__.py b/website_sale_product_pack/__manifest__.py index 3a3bf6873..1b54876f6 100644 --- a/website_sale_product_pack/__manifest__.py +++ b/website_sale_product_pack/__manifest__.py @@ -4,7 +4,7 @@ "name": "Website Sale Product Pack", "category": "E-Commerce", "summary": "Compatibility module of product pack with e-commerce", - "version": "17.0.2.0.1", + "version": "18.0.1.0.0", "license": "AGPL-3", "depends": ["website_sale", "sale_product_pack"], "data": ["views/templates.xml"], diff --git a/website_sale_product_pack/controllers/__init__.py b/website_sale_product_pack/controllers/__init__.py deleted file mode 100644 index 57a00ae3c..000000000 --- a/website_sale_product_pack/controllers/__init__.py +++ /dev/null @@ -1,2 +0,0 @@ -from . import main -from . import variant diff --git a/website_sale_product_pack/controllers/main.py b/website_sale_product_pack/controllers/main.py deleted file mode 100644 index 959847735..000000000 --- a/website_sale_product_pack/controllers/main.py +++ /dev/null @@ -1,27 +0,0 @@ -from odoo.http import request, route - -from odoo.addons.website_sale.controllers.main import WebsiteSale - - -class WebsiteSale(WebsiteSale): - @route() - def shop( - self, - page=0, - category=None, - search="", - min_price=0.0, - max_price=0.0, - ppg=False, - **post, - ): - request.update_context(whole_pack_price=True) - return super().shop( - page=page, - category=category, - search=search, - min_price=min_price, - max_price=max_price, - ppg=ppg, - **post, - ) diff --git a/website_sale_product_pack/controllers/variant.py b/website_sale_product_pack/controllers/variant.py deleted file mode 100644 index d7287b5c5..000000000 --- a/website_sale_product_pack/controllers/variant.py +++ /dev/null @@ -1,25 +0,0 @@ -from odoo.http import request, route - -from odoo.addons.website_sale.controllers.variant import WebsiteSaleVariantController - - -class WebsiteSaleVariantController(WebsiteSaleVariantController): - @route() - def get_combination_info_website( - self, - product_template_id, - product_id, - combination, - add_qty, - parent_combination=None, - **kwargs, - ): - request.update_context(whole_pack_price=True) - return super().get_combination_info_website( - product_template_id, - product_id, - combination, - add_qty, - parent_combination=parent_combination, - **kwargs, - ) diff --git a/website_sale_product_pack/models/product_template.py b/website_sale_product_pack/models/product_template.py index a0e3c7956..6cb1ad75e 100644 --- a/website_sale_product_pack/models/product_template.py +++ b/website_sale_product_pack/models/product_template.py @@ -48,3 +48,36 @@ def check_website_published(self): "pack_parents": ", ".join(published.mapped("name")), } ) + + def _get_additionnal_combination_info( + self, product_or_template, quantity, date, website + ): + """Override to add the information about renting for rental products""" + res = super()._get_additionnal_combination_info( + product_or_template, quantity, date, website + ) + + if not product_or_template.pack_ok: + return res + + currency = website.currency_id + pricelist = website.pricelist_id + res["price"] = pricelist.with_context(whole_pack_price=True)._get_product_price( + product=product_or_template, + quantity=quantity, + currency=currency, + ) + + return res + + def _get_sales_prices(self, website): + prices = super()._get_sales_prices(website) + pricelist = website.pricelist_id + + for template in self: + if not template.pack_ok: + continue + prices[template.id]["price_reduce"] = pricelist.with_context( + whole_pack_price=True + )._get_product_price(product=template, quantity=1.0) + return prices diff --git a/website_sale_product_pack/models/website.py b/website_sale_product_pack/models/website.py index e49825ced..3916b11f4 100644 --- a/website_sale_product_pack/models/website.py +++ b/website_sale_product_pack/models/website.py @@ -5,15 +5,3 @@ class Website(models.Model): _inherit = "website" - - def sale_get_order(self, force_create=False, update_pricelist=False): - """Communicate with product pack expansion method to check if it's necessary - to expand the product pack lines or not via context""" - if update_pricelist: - return super( - Website, self.with_context(update_pricelist=True) - ).sale_get_order(force_create, update_pricelist) - return super().sale_get_order( - force_create, - update_pricelist, - ) diff --git a/website_sale_product_pack/static/description/index.html b/website_sale_product_pack/static/description/index.html index 6099b7dcb..838070bbb 100644 --- a/website_sale_product_pack/static/description/index.html +++ b/website_sale_product_pack/static/description/index.html @@ -369,7 +369,7 @@

Website Sale Product Pack

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !! source digest: sha256:b253d0a32950c83c03fbde45ce4e7b7335fc773f15534306c65a0ec5344121b8 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! --> -

Beta License: AGPL-3 OCA/product-pack Translate me on Weblate Try me on Runboat

+

Beta License: AGPL-3 OCA/product-pack Translate me on Weblate Try me on Runboat

This module introduces compatibility of product packs with e-commerce:

  • In the cart summary, the components aren’t editable and are shown @@ -380,8 +380,8 @@

    Website Sale Product Pack

    sublines in the units count.
  • The cart summary shows the component lines hanging from the main one as well.
  • -
  • It’s ensured the the prices are shown correctly for the whole pack -and that they’re correctly summarized depending on the pack type.
  • +
  • It’s ensured the the prices are shown correctly for the whole pack and +that they’re correctly summarized depending on the pack type.

Table of contents

@@ -416,7 +416,7 @@

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.

+feedback.

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

@@ -449,7 +449,7 @@

Maintainers

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/product-pack project on GitHub.

+

This module is part of the OCA/product-pack project on GitHub.

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

diff --git a/website_sale_product_pack/static/tests/tours/website_sale_product_pack_tour.js b/website_sale_product_pack/static/tests/tours/website_sale_product_pack_tour.js index ddb7b6289..202db7b32 100644 --- a/website_sale_product_pack/static/tests/tours/website_sale_product_pack_tour.js +++ b/website_sale_product_pack/static/tests/tours/website_sale_product_pack_tour.js @@ -3,10 +3,9 @@ * License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). */ import {registry} from "@web/core/registry"; -import tourUtils from "@website_sale/js/tours/tour_utils"; +import * as tourUtils from "@website_sale/js/tours/tour_utils"; registry.category("web_tour.tours").add("create_components_price_order_line", { - test: true, url: "/shop", steps: () => [ ...tourUtils.searchProduct("Pack CPU (Detailed - Displayed Components Price)"), @@ -14,17 +13,18 @@ registry.category("web_tour.tours").add("create_components_price_order_line", { content: "select Pack CPU (Detailed - Displayed Components Price)", trigger: '.oe_product_cart:first a:contains("Pack CPU (Detailed - Displayed Components Price)")', + run: "click", }, { content: "click on add to cart", trigger: '#product_detail form[action^="/shop/cart/update"] #add_to_cart', + run: "click", }, tourUtils.goToCart(), ], }); registry.category("web_tour.tours").add("create_ignored_price_order_line", { - test: true, url: "/shop", steps: () => [ ...tourUtils.searchProduct("Pack CPU (Detailed - Ignored Components Price)"), @@ -32,17 +32,18 @@ registry.category("web_tour.tours").add("create_ignored_price_order_line", { content: "select Pack CPU (Detailed - Ignored Components Price)", trigger: '.oe_product_cart:first a:contains("Pack CPU (Detailed - Ignored Components Price)")', + run: "click", }, { content: "click on add to cart", trigger: '#product_detail form[action^="/shop/cart/update"] #add_to_cart', + run: "click", }, tourUtils.goToCart(), ], }); registry.category("web_tour.tours").add("create_totalized_price_order_line", { - test: true, url: "/shop", steps: () => [ ...tourUtils.searchProduct("Pack CPU (Detailed - Totalized Components Price)"), @@ -50,17 +51,18 @@ registry.category("web_tour.tours").add("create_totalized_price_order_line", { content: "select Pack CPU (Detailed - Totalized Components Price)", trigger: '.oe_product_cart:first a:contains("Pack CPU (Detailed - Totalized Components Price)")', + run: "click", }, { content: "click on add to cart", trigger: '#product_detail form[action^="/shop/cart/update"] #add_to_cart', + run: "click", }, tourUtils.goToCart(), ], }); registry.category("web_tour.tours").add("create_non_detailed_price_order_line", { - test: true, url: "/shop", steps: () => [ ...tourUtils.searchProduct("Non Detailed - Totalized Components Price"), @@ -68,17 +70,18 @@ registry.category("web_tour.tours").add("create_non_detailed_price_order_line", content: "select Non Detailed - Totalized Components Price", trigger: '.oe_product_cart:first a:contains("Non Detailed - Totalized Components Price")', + run: "click", }, { content: "click on add to cart", trigger: '#product_detail form[action^="/shop/cart/update"] #add_to_cart', + run: "click", }, tourUtils.goToCart(), ], }); registry.category("web_tour.tours").add("update_pack_qty", { - test: true, url: "/shop", steps: () => [ ...tourUtils.searchProduct("Pack CPU (Detailed - Displayed Components Price)"), diff --git a/website_sale_product_pack/views/templates.xml b/website_sale_product_pack/views/templates.xml index 1de66f327..f4e1583ac 100644 --- a/website_sale_product_pack/views/templates.xml +++ b/website_sale_product_pack/views/templates.xml @@ -11,7 +11,7 @@ class="js_quantity text-muted" t-att-data-line-id="line.id" t-att-data-product-id="line.product_id.id" - t-esc="int(line.product_uom_qty)" + t-out="int(line.product_uom_qty)" /> @@ -29,7 +29,7 @@ line.pack_parent_line_id - + line.product_id.image_128 and not line.pack_parent_line_id