Skip to content

Commit

Permalink
[IMP] website_sale_order_to_cart: Improve cancel error
Browse files Browse the repository at this point in the history
  • Loading branch information
unaiberis authored and anajuaristi committed Oct 21, 2024
1 parent a321ca6 commit e11be8a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
11 changes: 7 additions & 4 deletions website_sale_order_to_cart/controllers/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,12 @@ def cancel_sale_order(self, **kwargs):
if order_id:
sale_order = request.env["sale.order"].sudo().browse(int(order_id))
# Only cancel the order if the partner_id of the order is the user
# if sale_order.partner_id == request.env.user.partner_id: --> ...
# ... Doesn't work as expected
if sale_order and sale_order.state not in ["sale"]:
sale_order.action_cancel()
if (
sale_order
and sale_order.partner_id == request.env.user.partner_id
and sale_order.state not in ["sale"]
):
sale_order._action_cancel()
request.session["website_sale_cart_quantity"] = 0

return request.redirect("/shop")
2 changes: 1 addition & 1 deletion website_sale_order_to_cart/views/website_templates.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
expr="//div[hasclass('justify-content-between')]/div[1]"
position="after"
>
<t t-if="website_sale_order.id">
<t t-if="website_sale_order.id and website_sale_order.cart_quantity > 0">
<div>
<a
class="btn btn-primary mb32"
Expand Down

0 comments on commit e11be8a

Please sign in to comment.