Reputation: 1
I want to generate a warning near ADDTOCART when the ADDTOCART button clicked on odoo website.
XML file:
<t t-if="website.get_promo_code_error(delete=False)">
<div class="card bg-danger text-white mt16">
<div class="card-header clearfix">
<span class="float-left"><t t-esc="website.get_promo_code_error()" /></span>
</div>
</div>
</t>
Controler:
request.session['error_promo_code'] = "Can not add"
return request.redirect("/shop/product/%s" % product.id)
model:
def get_promo_code_error(self, delete=True):
error = request.session.get('error_promo_code')
if error and delete:
request.session.pop('error_promo_code')
return error
Upvotes: 0
Views: 441
Reputation: 2454
In Odoo there is a default
feature which provides on the website.
Goto Product -> Ecommerce tab -> there you find field Availability-> select this option Show inventory below a threshold and prevent sales if not enough stock
It will allow you to add the Availability Threshold, Add your product stock value like 10.
When you go on the webshop and add more than 10 qty for the same product it will trigger the message near the add to cart
button.
Upvotes: 0