Remove products from shopping cart - Website Odoo 9

余生长醉 提交于 2020-01-14 04:26:27

问题


I want to know how can i create a model (or extend existing one) for deleting a products from the Shopping cart in Odoo9.

The problem is described on the picture. I should add a a button and when i press it will delete the product completely doesn't matter which quantity is given.

Thank you in advance,

Kind regards, Igor


回答1:


A product is removed from your cart when its quantity reaches 0. Therefore try to use that function that already exists rather than creating your own javascript.

You can insert your button on website_sale/views/templates.xml On the template with the id="cart" and when clicked it should call a js script.

See on wesbsite_sale/static/src/js/website_sale.js check the part that starts with

$(oe_website_sale).on("change", ".oe_cart input.js_quantity[data-product-id]", function () {

This piece of code observes for changes in the quantity of the products and if the quantity reaches 0 it removes the whole line.

So you can change the quantity on the line you want to remove to 0 and the already existing code will remove the line.



来源:https://stackoverflow.com/questions/41877376/remove-products-from-shopping-cart-website-odoo-9

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!