Issue 9638

Title
ModelView's on_change_with() should return rec_name of m2o fields
Priority
feature
Status
chatting
Nosy list
albertca, ced, pokoli
Assigned to
Keywords
easy

Created on 2020-09-25.23:09:18 by albertca, last changed 7 months ago by ced.

Messages

Author: [hidden] (ced) Tryton committer Tryton translator
Date: 2020-09-26.22:15:00
We can not rely on issue9640 to get the rec_name (because of the context) so they are unrelated even if they will conflict if developed at the same time.
Author: [hidden] (pokoli) Tryton committer Tryton translator
Date: 2020-09-26.19:34:39
I think it will make sense to implement issue9640 before this issue.
Author: [hidden] (ced) Tryton committer Tryton translator
Date: 2020-09-26.10:43:40
To be clear, allowing returning Model instances in on_change_with* will not increase performance. But it will be some nice syntactic sugar for another issue9640.
Author: [hidden] (ced) Tryton committer Tryton translator
Date: 2020-09-26.01:16:03
On 2020-09-25 23:32, Albert Cervera i Areny wrote:
> While we're at it maybe we should allow on_change_with_*() methods to
> return an object instead of an id.

No because it will be pointless because it may not be correct instance
(with proper context) and it will prevent to use it as getter.
Author: [hidden] (albertca) Tryton committer
Date: 2020-09-25.23:32:34
Missatge de Cédric Krier <bugs@tryton.org> del dia dv., 25 de set.
2020 a les 23:22:
>
>
> Cédric Krier <cedric.krier@b2ck.com> added the comment:
>
> It is just a matter of ModelView.on_change_with filling the related dictionary.
>

Understood.

While we're at it maybe we should allow on_change_with_*() methods to
return an object instead of an id.

For example this line:

https://hg.tryton.org/modules/account/file/tip/period.py#l91

Would become:

 return self.fiscalyear.company
Author: [hidden] (ced) Tryton committer Tryton translator
Date: 2020-09-25.23:22:45
It is just a matter of ModelView.on_change_with filling the related dictionary.
Author: [hidden] (albertca) Tryton committer
Date: 2020-09-25.23:09:18
ModelView's on_change_with() [1] could return rec_name for m2o fields just like on_change() [2] does (although it's not what the comments say [3]).

This would avoid unnecessary requests from the client.


[1] https://hg.tryton.org/trytond/file/tip/trytond/model/modelview.py#l780
[2] https://hg.tryton.org/trytond/file/tip/trytond/model/modelview.py#l817
[3] https://hg.tryton.org/trytond/file/tip/trytond/model/modelview.py#l791
History
Date User Action Args
2020-09-26 22:15:00cedsetmessages: + msg60405
2020-09-26 19:34:39pokolisetmessages: + msg60403
2020-09-26 19:33:40pokolisetnosy: + pokoli
2020-09-26 10:43:41cedsetmessages: + msg60400
2020-09-26 01:16:03cedsetmessages: + msg60398
2020-09-25 23:32:34albertcasetmessages: + msg60396
2020-09-25 23:22:45cedsetstatus: unread -> chatting
messages: + msg60395
component: - tryton, proteus, sao
keyword: + easy
nosy: + ced
2020-09-25 23:09:18albertcacreate

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