From c9d7f8b0ed33652c2732ffced07a5ef80cebcc7c Mon Sep 17 00:00:00 2001 From: Adrien Widart Date: Thu, 14 Jul 2022 13:15:12 +0000 Subject: [PATCH] [FIX] website_sale_delivery: display delivery price with tax incl. When displaying the price of a shipping method, if its type is "Fixed Price", the option "Tax-Included" is not considered. To reproduce the issue: (Use demo data) 1. In Settings: - Product Prices: Tax-Included 2. Create two shipping methods: - SM01: - Provider: Fixed Price - Set a customer tax of 15% on the associated delivery product - Fixed Price: 100 - Published: True - SM02: - Provider: Based on Rules - Set a customer tax of 15% on the associated delivery product - Pricing: - If weight >= 0: Cost = 100 + 0 * weight - Published: True 3. Open the eShop 4. Add the Customizable Desk to the cart 5. Process checkout Error: When displaying the delivery methods, the price of SM01 is incorrect: $100 instead of $115. In other words: the tax is not in the price, as it should according to the settings. (The price of SM02 is correct: $115). The displaying of the shipping method price depends on the shipping method type: https://github.com/odoo/odoo/blob/68b08164e5de353ea0c48de92d0c0e028b49bc52/addons/website_sale_delivery/views/website_sale_delivery_templates.xml#L35-L46 If the type is `fixed`, we display the `fixed_price` field of the record (that is the value encoded on the shipping method form, so it does not include any tax) If the type is different, we just display a text: "Select to compute delivery rate". And, when loading the page, a JS widget gets and displays the rate for each shipping method (including SM01!) https://github.com/odoo/odoo/blob/204a2bb5553a275e785fbb9ccefbe26b06ef4ba1/addons/website_sale_delivery/static/src/js/website_sale_delivery.js#L38-L47 And in that case, the rate returned by the RPC includes the tax (if needed): https://github.com/odoo/odoo/blob/bc2615d8ab5135f21c488c5a260c59605b0da498/addons/website_sale_delivery/controllers/main.py#L57-L60 That is the reason why the displayed price of SM02 is correct. When the widget gets the prices, it uses the classes to find and replace the rate with the one returned by the server: https://github.com/odoo/odoo/blob/204a2bb5553a275e785fbb9ccefbe26b06ef4ba1/addons/website_sale_delivery/static/src/js/website_sale_delivery.js#L95-L105 However, if the shipping method type is `fixed`, it does not have the class `o_wsale_delivery_badge_price`, so the SM is not found and its type is not updated (that explains why the displayed price of SM01 is not correct). Because the widget gets the rate of all shipping methods, we should take advantage of that and let the widget apply the result on each method, even if the type is `fixed` OPW-2854341 closes odoo/odoo#96657 X-original-commit: ba210fe1dbcfe3026e6f34b94a5defd2fb4cd15d Signed-off-by: William Braeckman (wbr) Signed-off-by: Adrien Widart --- .../views/website_sale_delivery_templates.xml | 14 +------------- 1 file changed, 1 insertion(+), 13 deletions(-) diff --git a/addons/website_sale_delivery/views/website_sale_delivery_templates.xml b/addons/website_sale_delivery/views/website_sale_delivery_templates.xml index e8edf6fe15d..97a52b9e857 100644 --- a/addons/website_sale_delivery/views/website_sale_delivery_templates.xml +++ b/addons/website_sale_delivery/views/website_sale_delivery_templates.xml @@ -18,19 +18,7 @@