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 authored and matiasperalta1 committed Jan 17, 2025
1 parent db0b2c6 commit b070ee4
Show file tree
Hide file tree
Showing 10 changed files with 54 additions and 84 deletions.
10 changes: 5 additions & 5 deletions website_sale_product_pack/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@ 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|
Expand Down Expand Up @@ -66,7 +66,7 @@ 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 Down Expand Up @@ -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.
4 changes: 2 additions & 2 deletions website_sale_product_pack/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@
"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"],
"assets": {
"web.assets_tests": [
"website_sale_product_pack/static/tests/tours/website_sale_product_pack_tour.js",
"website_sale_product_pack/static/tests/tours/website_sale_product_pack_tour.esm.js",
],
},
"author": "Tecnativa, Odoo Community Association (OCA)",
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
27 changes: 0 additions & 27 deletions website_sale_product_pack/controllers/main.py
Original file line number Diff line number Diff line change
@@ -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,
)
25 changes: 0 additions & 25 deletions website_sale_product_pack/controllers/variant.py
Original file line number Diff line number Diff line change
@@ -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,
)
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

Check warning on line 61 in website_sale_product_pack/models/product_template.py

View check run for this annotation

Codecov / codecov/patch

website_sale_product_pack/models/product_template.py#L61

Added line #L61 was not covered by tests

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,
)
6 changes: 3 additions & 3 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 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 @@ -3,82 +3,85 @@
* 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)"),
{
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 b070ee4

Please sign in to comment.