OCA/e-commerce

[BUG] website_sale_checkout_skip_payment not compatible with delivery methods

Closed this issue · 4 comments

Module

website_sale_checkout_skip_payment
Tested on version 12 Community Edition

Describe the bug

When buying product from eCommerce, I select a delivery method available (not the first one). On the Sale Order in backend, the wrong delivery method is selected. It's always the first one in the list of delivery methods configuration that is selected on the SO.

To Reproduce

Affected versions: version 12

Steps to reproduce the behavior:

  1. Install website_sale_checkout_skip_payment and website_delivery.
  2. Configure the customer partner so that the payment screen will be skipped
  3. Configure 2 delivery methods and publish them
  4. Go on eCommerce and buy a product. Select the second delivery method.
  5. Validate
  6. Go on SO in backend and check the delivery method: wrong method is selected.

Expected behavior
6. The delivery method chosen by the customer on the eCommerce is selected o
Delivery Methods - Odoo
n the SO on the backend
SO002 - wrong delivery method in backend - Odoo
Administrator_customer_config_skip - Odoo
Payment My Website_Delivery

The issue happens at the last step
image
Here, when changing the delivery method, the method _update_website_sale_delivery should be triggered by this JS code.

But when the customer is allowed to skip_payment, the JS code throws an error at this line :

Uncaught TypeError: 
``$pay_button.data(...) is undefined
_onCarrierClick http://localhost:8012/web/content/985-5287018/1/web.assets_frontend.js:295

at this line

so the method is not tiggered, the carrier is not updated, and the first one on the list is used.

I think this might be because the payment route is skipped and we go directly to the confirmation route (like below).

<form target="_self" action="/shop/confirmation" method="post" class="float-right">
<input type="hidden" name="csrf_token" t-att-value="request.csrf_token()" />
<a role="button" class="btn btn-primary a-submit" href="#">
<span>Confirm Order <span class="fa fa-chevron-right"></span></span>
</a>

However I don't have a clearer idea.
@sergio-teruel Do you know a way to fix this issue ?

Sorry @victor-champonnois The website_sale_checkout_skip_payment module has not include any JS code, so I think that this error is related to other module...

@sergio-teruel I took a look and it seems to be related to the absence of the payment button element. https://github.com/odoo/odoo/blob/c53081f10befd4f1c98e46a450ed3bc71a6246ed/addons/website_sale_delivery/static/src/js/website_sale_delivery.js#L12

Anyway, I couldn't reproduce the bug in the versions we're currently supporting for our customers (>13).

So @victor-champonnois feel free to propose a PR patching de issue for 12.0

There hasn't been any activity on this issue in the past 6 months, so it has been marked as stale and it will be closed automatically if no further activity occurs in the next 30 days.
If you want this issue to never become stale, please ask a PSC member to apply the "no stale" label.