web
web copied to clipboard
[16.0][IMP] web_timeline - for relational group fields use default order in related model, fix for default_group_by attribute no relational
Hi @tarteo, some modules you are maintaining are being modified, check this out!
@IJOL, could you please give me an example or use case to test this PR? Thanks.
TT50999
@IJOL, could you please give me an example or use case to test this PR? Thanks.
TT50999
if your timeline default_group_by field is a many2* field and the related model has a sequence field it used to order the groups in the timeline left area, in the example in https://github.com/OCA/project/blob/16.0/project_timeline/views/project_project_view.xml if you change default_group_by to project_id which i think you can in that context, with my change the sequence field in the project model should be used as order for the groups in the timeline, thus giving the same order in the timeline that projects has
The order should be defined by the model itself with their _order clause, being the sequence or whatever, but it shouldn't be hardcoded. The module should rely on the existing order.
this is exactly what the sequence field does in other contexts like list , trees or whatever, if the group is a model wiith no seuqence, or a plain field it does nothing
That's only if the widget="handle" is present AFAIK, but it's not the same context here, as we can't drag and drop for changing such sequence. I insist that we must rely on the model order.
The problem is that Js part reworks the groups, because your are no reading from a projects query that should be ordered you are doingthe groups by the extension it self, and gives up any order i think in the context i use it, and in the example given you order the group as it is stored in the tasks, so no order in projects at all
Just confused the example i use it in project.task context model and i try to group by project_id..
When grouping by project, you should query Odoo to return the ordered recordset including all the existing projects.
When grouping by project, you should query Odoo to return the ordered recordset including all the existing projects.
Ok, get your point it should be easy to implement that way too, not actually able to remember why i ended in this solution, not so sure i have now the time to do it.. i will push something if i can
Great, let us know. @carlos-lopez-tecnativa FYI
@IJOL are you saying when grouping records, the groups are not ordered by the corresponding model's order?
this is exactly what the sequence field does in other contexts like list , trees or whatever, if the group is a model wiith no seuqence, or a plain field it does nothing
Can you send me a link to where Odoo does this in the tree view etc. Does it there look at hard-coded sequence or _order? Thanks in advance
Actually the js code for extension, only gets the group id from data ( in the examples i put in from tasks and the group_id is the project_id) and if it a relational field gets the name from the corresponding model, but the order is the one obtained from the data, the order in which the groups are named in the data to be exact, mi first proposed change tried to not mess too much with the Js part and simply try to assume that if the related model in the group_id has a sequence field this was the order the group id model was supposed to do, and do nothing in any other case, just a cheap way to do what actually the extension do badly, that is the groups had no order at all, last friday i got convinced by Pedro Baeza to getting the order from the model itself by doing a simple search of all related model data and extract the order from there, as i was assuming naively that the order of the related model comes from a field named sequence in the model....
Saludos,
Ignacio J.Ortega skype:ignacioj.ortega
El mar, 1 oct 2024 a las 9:57, Dennis Sluijk @.***>) escribió:
@IJOL https://github.com/IJOL are you saying when grouping records, the groups are not ordered by the corresponding model's order?
this is exactly what the sequence field does in other contexts like list , trees or whatever, if the group is a model wiith no seuqence, or a plain field it does nothing
Can you send me a link to where Odoo does this in the tree view etc. Does it there look at hard-coded sequence or _order? Thanks in advance
— Reply to this email directly, view it on GitHub https://github.com/OCA/web/pull/2929#issuecomment-2385055139, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAXHYV754KFAPHOFAOWWP53ZZJIXBAVCNFSM6AAAAABNWI4FPCVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDGOBVGA2TKMJTHE . You are receiving this because you were mentioned.Message ID: @.***>
As suggested the group's order is obtained from the related model if the default_group_by is relational ( Many2one or Many2many ), i added a fix for other issues i'm having when the group field if is not relational, need reviewers though..
@carlos-lopez-tecnativa @tarteo @pedrobaeza
ping @carlos-lopez-tecnativa
ping @pedrobaeza
@IJOL can you rebase, please? Thanks!