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 Dec 23, 2024
1 parent db0b2c6 commit f0dd428
Show file tree
Hide file tree
Showing 10 changed files with 68 additions and 98 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.
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
Original file line number Diff line number Diff line change
@@ -1,2 +0,0 @@
from . import main
from . import variant
26 changes: 1 addition & 25 deletions website_sale_product_pack/controllers/main.py
Original file line number Diff line number Diff line change
@@ -1,27 +1,3 @@
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,
)
from odoo.addons.website.controllers.main import Website
24 changes: 0 additions & 24 deletions website_sale_product_pack/controllers/variant.py
Original file line number Diff line number Diff line change
@@ -1,25 +1 @@
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,
)
33 changes: 33 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,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
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
Expand Up @@ -6,43 +6,44 @@ 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)"),
Expand All @@ -60,7 +61,6 @@ registry.category("web_tour.tours").add("create_totalized_price_order_line", {
});

registry.category("web_tour.tours").add("create_non_detailed_price_order_line", {
test: true,
url: "/shop",
steps: () => [
...tourUtils.searchProduct("Non Detailed - Totalized Components Price"),
Expand All @@ -78,7 +78,6 @@ registry.category("web_tour.tours").add("create_non_detailed_price_order_line",
});

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 f0dd428

Please sign in to comment.