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

In Odoo there is a
defaultfeature which provides on the website.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 cartbutton.