Overslaan naar inhoud
Menu
Je moet geregistreerd zijn om te kunnen communiceren met de community.
Deze vraag is gerapporteerd
1 Beantwoorden
1583 Weergaven

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."))

Avatar
Annuleer
Beste antwoord

Hey, 


Maybe you can write onchange it will fit your needs.

Thanks

Avatar
Annuleer
Auteur

Hi Jay,

Thank you for your response. However, from my understanding, the onchange methods are executed not only when modifying values from the UI but also when modifying them from the code.

So, I would encounter the same issue while attempting to differentiate whether that change originates from a UI modification.

Gerelateerde posts Antwoorden Weergaven Activiteit
5
mei 25
45268
2
jul. 25
3282
2
jul. 25
3005
2
jun. 25
1800
0
mei 25
14