Having ModelSQL.write obey readonly set in states.

19 views
Skip to first unread message

Jon Levy

unread,
Aug 16, 2016, 2:29:15 PM8/16/16
to tryton
I have a bit of code that calls ModelSQL.write([active_records], {values}) and have found that it will write to a field even if that field is readonly, per the `states` of the Model.  Is this the expected behavior, and is there a way to have `write` honor the constraint set in `states`?

I'm using 3.4

Cédric Krier

unread,
Aug 16, 2016, 3:35:16 PM8/16/16
to tryton
This is the expected behaviour for now.
The read-only had always meaning only for user but we should try to
enforce it, see https://bugs.tryton.org/issue4207

But if you need a really strong enforcement, you must override the write
method to raise an error in this case.

--
Cédric Krier - B2CK SPRL
Email/Jabber: cedric...@b2ck.com
Tel: +32 472 54 46 59
Website: http://www.b2ck.com/
Reply all
Reply to author
Forward
0 new messages