I would like to determine whether the constraint has been triggered due to a user-initiated change from the Odoo UI or if it has been triggered from within the internal code of another application.
The code would be something like that:
class StockMove(models.Model):
_inherit = "stock.move"
@api.constrains('sequence')
def _constrains_sequence(self):
if comes_from_UI:
raise ValidationError(_("Not allowed to change the sequence of moves from the picking."))