Hi,
From onchange you can return warning like this,
@api.onchange('product_uom_qty')
def _onchange_product_uom_qty(self):
if self.state == 'sale' and self.product_id.type in ['product', 'consu'] and self.product_uom_qty < self._origin.product_uom_qty:
warning_mess = {
'title': _('Ordered quantity decreased!'),
'message' : _('You are decreasing the ordered quantity! Do not forget to manually update the delivery order if needed.'),
}
return {'warning': warning_mess}
return {}
But this won't stop the execution of the code. If you want to show validation in the onchange itself you can try the above code and reset the wrongly entered value to null or False, and ask the user to enter it again correctly or by making the required field.
Else you can try the solution that Mr Sudhir has mentioned with the ValidationError using constrains, see this: How To Add Constrains For A Field in Odoo12
Thanks
i have tried 13 in the code too,