I am using Odoo 11 and I want to display a Warning popup in a @api.constraint method. The warning popup that I want to display has two buttons, the first is an OK button used to ignore the warning and the other one is a Cancel button used to attempt the saving operation, it' s similar to the warning popup that odoo uses like on the picture below :
I searched a lot on the web and I found different proposed solutions like using Wizard, exception.Warning() and osv.except_osv(), but unfortunately no one of this solution gives me exactly what I want.
Any help please?
You can raise warning message by different ways. I have created message related to stock quantity by this way:
if self.qty > new_qty:
message = _('You plan to sell %s quantity but you only have %s available in %s warehouse.') % \
(self.qty, self.product_id.virtual_available, self.order_id.warehouse_id.name)
mess= {
'title': _('Not enough inventory!'),
'message' : message
}
return {'warning': mess}
This return same wizard of warning as you want and as shown given image.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With