Issue 6038

Title
ModelSQL.__raise_integrity_error raises confusing errors when using Many2One
Priority
bug
Status
resolved
Nosy list
afibanez, ced, jcavallo, kstenger, reviewbot, roundup-bot
Assigned to
ced
Keywords
review

Created on 2016-11-16.10:15:21 by afibanez, last changed 47 months ago by ced.

Messages

Author: [hidden] (ced) Tryton committer Tryton translator
Date: 2016-12-08.15:43:15
No it is just behaviour.
Author: [hidden] (jcavallo)
Date: 2016-12-08.15:36:00
Could this be backported in previous versions ?

The issue also exists at least on 4.0.
New changeset 1362c57627fc by C?dric Krier in branch 'default':
Use original transaction to check created/deleted records in __raise_integrity_error
http://hg.tryton.org/trytond/rev/1362c57627fc
Author: [hidden] (ced) Tryton committer Tryton translator
Date: 2016-11-26.19:16:17
The proposed solution is not right because it does not fix the problem in case of deeper nested creation.
Indeed the design was already made to take care of this with the created/deleted_records on Transaction but the problem is that __raise_integrity_error is run under a new transaction.
So here is review29781002 which ensure the original transaction is used for created/deleted_records.
Author: [hidden] (afibanez)
Date: 2016-11-16.18:46:11
Ced, the problem is that the many2one record not exists before fails at creation because a required field is not filled. The error is a lot more meaningful if says field required
Author: [hidden] (ced) Tryton committer Tryton translator
Date: 2016-11-16.18:36:19
I'm not sure to understand the problem. If really the value of the Many2One does not exist, the error message is not wrong. Why should the required constraint be necessary the first to check?
Author: [hidden] (kstenger) Tryton committer
Date: 2016-11-16.14:47:05
Based on your review, it's Many2One, not One2Many
Author: [hidden] (afibanez)
Date: 2016-11-16.10:38:08
Changed the title, @pokoli pointed to me that only happens when working with One2Many fields
Author: [hidden] (afibanez)
Date: 2016-11-16.10:31:36
To review in review29741002
Author: [hidden] (afibanez)
Date: 2016-11-16.10:15:21
When ModelSQL is created, written or deleted checks integrity with the method __raise_integrity_error.

This method checks the fields of the model, and assert that required fields are filled and many2one relations are correct.

The issue is that if one many2one field is checked before all the required fields are checked, it will raise an error:
"The value \"%(value)s\" of field \"%(field)s\" on \"%(model)s\" doesn't exist.", 
instead of the real error, that is:
"The field \"%(field)s\" on \"%(model)s\" is required.".

It can be improved by checking first all the required field and after all the relations.
History
Date User Action Args
2016-12-08 15:43:16cedsetstatus: chatting -> resolved
messages: + msg30618
2016-12-08 15:36:00jcavallosetstatus: resolved -> chatting
nosy: + jcavallo
messages: + msg30616
2016-11-28 00:01:57roundup-botsetstatus: testing -> resolved
nosy: + roundup-bot
messages: + msg30493
2016-11-26 19:31:53reviewbotsetmessages: + msg30473
2016-11-26 19:16:27cedsetreviews: 29741002 -> 29781002
2016-11-26 19:16:17cedsetassignedto: afibanez -> ced
type: behavior
messages: + msg30472
2016-11-16 18:46:11afibanezsetmessages: + msg30331
2016-11-16 18:36:20cedsetnosy: + ced
messages: + msg30329
2016-11-16 18:04:43reviewbotsetmessages: + msg30328
2016-11-16 17:33:18reviewbotsetmessages: + msg30327

Showing 10 items. Show all history (warning: this could be VERY long)