问题
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