Odoo Help


Steps to follow for reset the shopping cart in Odoo V8 Website.

Pascal Tremblay
on 7/3/15, 5:19 PM 2,944 views

Hello guys,

What is the trick to reset the cart? I would want a button in the cart to delete all lines in it.

Thanks to help..


Emipro Technologies Pvt. Ltd.

--Emipro Technologies Pvt. Ltd.--
| 6 7 8
Rajkot, India
--Emipro Technologies Pvt. Ltd.--

Being an emerging leader in IT market since 2011, Emipro Technologies Pvt. Ltd. has been providing a wide range of business solutions in Odoo & Magento. We are pleased to have a large pool of contented customers with our meticulous work in the domain of ERP & e-Commerce. A ray of relief & satisfaction to  our customers heart by our successful deployment in their organization, purely represents our success in Odoo platform. Hence, we take pride for being an Odoo partner with a vision of expanding our strategic alliances with our customers to offer them high value-added, trustworthy & cost effective solutions.


Since establishment, our business has span across 11 countries of the world. Our customers are companies of all sizes ranging from start-ups to large enterprises, who realize that they need a professional business solutions to generate revenue streams, establish proper communication channels or streamline business operations. Standing with strong determination of customer satisfaction, observing each minute detail of their business processes, providing proper guidance and moving forth to develop product accordingly adds our value and reliability among our customers. 


We are blessed with efficient, passionate & eclectic young developers who have come across almost all kinds of business profiles, working with full dedication, applying creativity & new features in existing modules and completing customer's projects successfully on predefined target. Our in-depth knowledge while giving business solutions in Odoo allows us to offer following services to our customers :


  • Consulting
  • Installation, Configuration & Customization
  • Training & Support
  • Maintenance
  • Upgradation
  • Documentation
  • Crafting community modules
  • Drafting videos on demand
  • Smart Apps development

We will be :) to welcome you @ www.emiprotechnologies.com to solve any kind of your business needs around Odoo. However we are just an inch away from you by email info@emiprotechnologies.com or a tweet to @EmiproTech

Emipro Technologies Pvt. Ltd.
On 7/4/15, 1:10 AM

Hi Pascal,

You can make your own custom module to manage reset the cart by following below steps...

Step 1. Inherit template of cart and make one .xml file.

<template id="clear_cart_button" inherit_id="website_sale.cart" customize_show="True" name="Clear Cart Button">
<xpath expr="//a[@href='/shop/checkout']" position="before">
    <a href="" id="clear_cart_button" class="btn btn-default mb32">&lt;span class="fa fa-trash-o"/> Clear Cart&lt;/a> 
<!-- This template is use to add .js file inside webiste. -->
<template id="assets_frontend" inherit_id="website.assets_frontend" name="Shop">
<xpath expr="." position="inside">
    <script type="text/javascript" src="/website_sale_clear_cart/static/src/js/website_sale_clear_cart.js"></script> 

Step 2. Make .js file inside /startic/src/js folder to make click event of the link.

$(document).ready(function () {
$('.oe_website_sale').each(function () {
var oe_website_sale = this;
$(oe_website_sale).on("click", ".oe_cart #clear_cart_button", function () {
openerp.jsonRpc("/shop/clear_cart", "call", {}).then(function(){
return false;

Step 3. Add controller inside .py file to manage request of clear cart.

class pos_website_sale(http.Controller):
    @http.route(['/shop/clear_cart'], type='json', auth="public", website=True)
    def clear_cart(self):
        order = request.website.sale_get_order()
        if order:
            for line in order.website_order_line:

That's it. It will add one functionality inside cart template for clear/remove all products from the selected cart.

I am sure that it is very useful for you.

Free App is out at Odoo Apps Store now. You can download  and use it.

Odoo Technical notes is published for this. You can view Technical Stpes to reset a shopping cart in Odoo 8 Website  and review it. 

Thanks for all. Very nice from you. I'm testing. For the moment, I have the button but it doesn't work.

Pascal Tremblay
on 7/4/15, 7:38 AM

Ok, it works well now! 1000 thanks for your quick answer.

Pascal Tremblay
on 7/4/15, 7:44 AM

Thanks for the post! Do you have any suggestions on how this could be done by order line only? The use case is I want to add an 'x' or trash can icon to the order lines in my own module for a quick cart dropdown in the nav/header (already built), and in the shopping cart order lines.

I'm just wondering if there is an easy way to delete order lines given the method shown above or an alternative.

Luke Branch
on 7/8/15, 6:23 AM

@Luke I've did something similar. The view: https://github.com/Yenthe666/Dev/blob/master/aa_houbolak/templates.xml#L358 The JS: https://github.com/Yenthe666/Dev/blob/master/aa_houbolak/static/src/js/houbolak.js#L23-L32 This pretty much shows a delete icon and then deletes the specific line through XML-RPC. I hope this helps you :)

on 8/17/15, 9:36 AM
Niraj Pajwani
On 10/14/15, 6:51 AM

Thanks a lot.

Really its very helpful for me as well as other also.

About This Community

This platform is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.


Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now

Question tools

3 follower(s)


Asked: 7/3/15, 5:19 PM
Seen: 2944 times
Last updated: 11/26/15, 9:27 AM