From d611faeea79a84f333228257b342985b00d2f2ce Mon Sep 17 00:00:00 2001 From: nie Date: Wed, 2 Dec 2020 10:08:54 +0000 Subject: [PATCH] [FIX] website_sale_delivery: tax not included in delivery options Steps: - Install eCommerce and a delivery method (here, UPS) - Go to Website > Configuration > Settings - Select Pricing > Product Prices > Tax-Included - Go to Configuration > eCommerce/Shipping Methods - Click UPS US and publish it - Go to the eCommerce - Add a product to the cart (here, Customizable Desk) - Click My Cart > Process Checkout - UPS has a delivery price - Select UPS Bug: The delivery price of the UPS line has changed Explanation: When we first arrive to the delivery selection, prices are computed by calling the carrier's API and are shown straight away. However, when a list item is clicked, a "Delivery" sale order line is generated and the price on the list is copied from that sale order line. Before 13.0, we explicitly asked customers to click on a delivery method to see its price. Now, it's automatically computed. This fix makes sure the taxes are applied to the delivery prices before clicking on them. opw:2392281 closes odoo/odoo#62806 X-original-commit: bc2615d8ab5135f21c488c5a260c59605b0da498 Signed-off-by: backspac --- addons/website_sale_delivery/controllers/main.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/addons/website_sale_delivery/controllers/main.py b/addons/website_sale_delivery/controllers/main.py index 09b03d78f6e..bd8a7649020 100644 --- a/addons/website_sale_delivery/controllers/main.py +++ b/addons/website_sale_delivery/controllers/main.py @@ -43,6 +43,22 @@ class WebsiteSaleDelivery(WebsiteSale): carrier = request.env['delivery.carrier'].sudo().browse(int(carrier_id)) rate = carrier.rate_shipment(order) if rate.get('success'): + tax_ids = carrier.product_id.taxes_id.filtered(lambda t: t.company_id == order.company_id) + if tax_ids: + fpos = order.fiscal_position_id + tax_ids = fpos.map_tax(tax_ids, carrier.product_id, order.partner_shipping_id) + taxes = tax_ids.compute_all( + rate['price'], + currency=order.currency_id, + quantity=1.0, + product=carrier.product_id, + partner=order.partner_shipping_id, + ) + if request.env.user.has_group('account.group_show_line_subtotals_tax_excluded'): + rate['price'] = taxes['total_excluded'] + else: + rate['price'] = taxes['total_included'] + res['status'] = True res['new_amount_delivery'] = Monetary.value_to_html(rate['price'], {'display_currency': order.currency_id}) res['is_free_delivery'] = not bool(rate['price'])