Skip to content

Commit

Permalink
[MIG] website_sale_product_pack: Migration to 18.0
Browse files Browse the repository at this point in the history
  • Loading branch information
ALopez-Adhoc committed Jan 22, 2025
1 parent db0b2c6 commit fc791c8
Show file tree
Hide file tree
Showing 11 changed files with 93 additions and 104 deletions.
44 changes: 22 additions & 22 deletions website_sale_product_pack/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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**

Expand All @@ -56,17 +56,17 @@ 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
===========

Bugs are tracked on `GitHub Issues <https://github.com/OCA/product-pack/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 <https://github.com/OCA/product-pack/issues/new?body=module:%20website_sale_product_pack%0Aversion:%2017.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
`feedback <https://github.com/OCA/product-pack/issues/new?body=module:%20website_sale_product_pack%0Aversion:%2018.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.

Expand All @@ -81,13 +81,13 @@ Authors
Contributors
------------

- `Tecnativa <https://www.tecnativa.com>`__:
- `Tecnativa <https://www.tecnativa.com>`__:

- David Vidal
- David Vidal

- `ADHOC SA <https://www.adhoc.com.ar>`__:
- `ADHOC SA <https://www.adhoc.com.ar>`__:

- Nicolas Mac Rouillon
- Nicolas Mac Rouillon

Maintainers
-----------
Expand All @@ -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 <https://github.com/OCA/product-pack/tree/17.0/website_sale_product_pack>`_ project on GitHub.
This module is part of the `OCA/product-pack <https://github.com/OCA/product-pack/tree/18.0/website_sale_product_pack>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
1 change: 0 additions & 1 deletion website_sale_product_pack/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
from . import models
from . import controllers
2 changes: 1 addition & 1 deletion website_sale_product_pack/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"],
Expand Down
2 changes: 0 additions & 2 deletions website_sale_product_pack/controllers/__init__.py

This file was deleted.

27 changes: 0 additions & 27 deletions website_sale_product_pack/controllers/main.py

This file was deleted.

25 changes: 0 additions & 25 deletions website_sale_product_pack/controllers/variant.py

This file was deleted.

54 changes: 54 additions & 0 deletions website_sale_product_pack/models/product_template.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,3 +48,57 @@ def check_website_published(self):
"pack_parents": ", ".join(published.mapped("name")),
}
)

def _get_combination_info(
self,
combination=False,
product_id=False,
add_qty=1.0,
parent_combination=False,
only_template=False,
):
"""Override to add the information about renting for rental products"""
return super(
ProductTemplate, self.with_context(whole_pack_price=True)
)._get_combination_info(
combination=combination,
product_id=product_id,
add_qty=add_qty,
parent_combination=parent_combination,
only_template=only_template,
)

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 product_or_template.pack_ok:
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):
"""Override to add the price of the pack itself"""
packs, no_packs = self.with_context(whole_pack_price=True).split_pack_products()
prices = super(ProductTemplate, no_packs)._get_sales_prices(website)
if packs:
pricelist = website.pricelist_id
for pack in packs:
prices[pack.id] = {
"price_reduce": pricelist.with_context(
whole_pack_price=True
)._get_product_price(product=pack, quantity=1.0)
}
return prices
12 changes: 0 additions & 12 deletions website_sale_product_pack/models/website.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
)
10 changes: 5 additions & 5 deletions website_sale_product_pack/static/description/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,7 @@ <h1 class="title">Website Sale Product Pack</h1>
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:b253d0a32950c83c03fbde45ce4e7b7335fc773f15534306c65a0ec5344121b8
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
<p><a class="reference external image-reference" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external image-reference" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/licence-AGPL--3-blue.png" /></a> <a class="reference external image-reference" href="https://github.com/OCA/product-pack/tree/17.0/website_sale_product_pack"><img alt="OCA/product-pack" src="https://img.shields.io/badge/github-OCA%2Fproduct--pack-lightgray.png?logo=github" /></a> <a class="reference external image-reference" href="https://translation.odoo-community.org/projects/product-pack-17-0/product-pack-17-0-website_sale_product_pack"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external image-reference" href="https://runboat.odoo-community.org/builds?repo=OCA/product-pack&amp;target_branch=17.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
<p><a class="reference external image-reference" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external image-reference" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/licence-AGPL--3-blue.png" /></a> <a class="reference external image-reference" href="https://github.com/OCA/product-pack/tree/18.0/website_sale_product_pack"><img alt="OCA/product-pack" src="https://img.shields.io/badge/github-OCA%2Fproduct--pack-lightgray.png?logo=github" /></a> <a class="reference external image-reference" href="https://translation.odoo-community.org/projects/product-pack-18-0/product-pack-18-0-website_sale_product_pack"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external image-reference" href="https://runboat.odoo-community.org/builds?repo=OCA/product-pack&amp;target_branch=18.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
<p>This module introduces compatibility of product packs with e-commerce:</p>
<ul class="simple">
<li>In the cart summary, the components aren’t editable and are shown
Expand All @@ -380,8 +380,8 @@ <h1 class="title">Website Sale Product Pack</h1>
sublines in the units count.</li>
<li>The cart summary shows the component lines hanging from the main one
as well.</li>
<li>It’s ensured the the prices are shown correctly for the whole pack
and that they’re correctly summarized depending on the pack type.</li>
<li>It’s ensured the the prices are shown correctly for the whole pack and
that they’re correctly summarized depending on the pack type.</li>
</ul>
<p><strong>Table of contents</strong></p>
<div class="contents local topic" id="contents">
Expand Down Expand Up @@ -416,7 +416,7 @@ <h1><a class="toc-backref" href="#toc-entry-3">Bug Tracker</a></h1>
<p>Bugs are tracked on <a class="reference external" href="https://github.com/OCA/product-pack/issues">GitHub Issues</a>.
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
<a class="reference external" href="https://github.com/OCA/product-pack/issues/new?body=module:%20website_sale_product_pack%0Aversion:%2017.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
<a class="reference external" href="https://github.com/OCA/product-pack/issues/new?body=module:%20website_sale_product_pack%0Aversion:%2018.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
<p>Do not contact contributors directly about support or help with technical issues.</p>
</div>
<div class="section" id="credits">
Expand Down Expand Up @@ -449,7 +449,7 @@ <h2><a class="toc-backref" href="#toc-entry-7">Maintainers</a></h2>
<p>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.</p>
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/product-pack/tree/17.0/website_sale_product_pack">OCA/product-pack</a> project on GitHub.</p>
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/product-pack/tree/18.0/website_sale_product_pack">OCA/product-pack</a> project on GitHub.</p>
<p>You are welcome to contribute. To learn how please visit <a class="reference external" href="https://odoo-community.org/page/Contribute">https://odoo-community.org/page/Contribute</a>.</p>
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,84 +1,86 @@
/** @odoo-module **/
/* Copyright 2021 Tecnativa - David Vidal
* License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). */

import * as tourUtils from "@website_sale/js/tours/tour_utils";
import {registry} from "@web/core/registry";
import 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)"),
{
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)"),
{
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)"),
{
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"),
{
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)"),
Expand Down
4 changes: 2 additions & 2 deletions website_sale_product_pack/views/templates.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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)"
/>
</xpath>
<!-- We don't want to allow to delete pack components -->
Expand All @@ -29,7 +29,7 @@
line.pack_parent_line_id
</attribute>
</xpath>
<xpath expr="//div[@t-else='']" position="attributes">
<xpath expr="//div[@t-field='line.product_id.image_128']" position="attributes">
<attribute
name="t-if"
>line.product_id.image_128 and not line.pack_parent_line_id</attribute>
Expand Down

0 comments on commit fc791c8

Please sign in to comment.