diff options
| author | nie <nie@odoo.com> | 2020-12-02 10:08:54 +0000 |
|---|---|---|
| committer | nie <nie@odoo.com> | 2020-12-03 10:49:12 +0000 |
| commit | c1949169b2634b223dcf05d99841e6e2ce972dba (patch) | |
| tree | 786467118671a85e6f88caeb464b4401d5e87093 /addons/website_sale_delivery | |
| parent | 8520a3ef14dd1e79ace1dea70eebeffb4f21f0eb (diff) | |
[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#62801
X-original-commit: bc2615d8ab5135f21c488c5a260c59605b0da498
Signed-off-by: backspac <backspac@users.noreply.github.com>
Diffstat (limited to 'addons/website_sale_delivery')
| -rw-r--r-- | addons/website_sale_delivery/controllers/main.py | 16 |
1 files changed, 16 insertions, 0 deletions
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']) |
