Skip to content

Commit

Permalink
[16.0][FIX] website_sale_product_pack: detailed displayed components …
Browse files Browse the repository at this point in the history
…price on website
  • Loading branch information
augusto-weiss committed Oct 25, 2023
1 parent 820f59e commit 94911f8
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 0 deletions.
2 changes: 2 additions & 0 deletions product_pack/models/product_product.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ def price_compute(
)
for product in packs.with_context(prefetch_fields=False):
pack_price = 0.0
if product.product_tmpl_id.pack_component_price == "detailed":
pack_price = product.list_price
for pack_line in product.sudo().pack_line_ids:
pack_price += pack_line.get_price()
pricelist_id_or_name = self._context.get("pricelist")
Expand Down
1 change: 1 addition & 0 deletions website_sale_product_pack/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
from . import models
from . import controllers
1 change: 1 addition & 0 deletions website_sale_product_pack/controllers/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import variant
23 changes: 23 additions & 0 deletions website_sale_product_pack/controllers/variant.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
from odoo import http

from odoo.addons.website_sale.controllers.variant import WebsiteSaleVariantController


class WebsiteSaleVariantController(WebsiteSaleVariantController):
@http.route(
["/sale/get_combination_info_website"],
type="json",
auth="public",
methods=["POST"],
website=True,
)
def get_combination_info_website(
self, product_template_id, product_id, combination, add_qty, **kw
):
if "context" in kw:
kw["context"].update({"whole_pack_price": True})

Check warning on line 18 in website_sale_product_pack/controllers/variant.py

View check run for this annotation

Codecov / codecov/patch

website_sale_product_pack/controllers/variant.py#L18

Added line #L18 was not covered by tests
else:
kw["context"] = {"whole_pack_price": True}
return super(WebsiteSaleVariantController, self).get_combination_info_website(
product_template_id, product_id, combination, add_qty, **kw
)

0 comments on commit 94911f8

Please sign in to comment.