-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[16.0][IMP] web_timeline - for relational group fields use default order in related model, fix for default_group_by attribute no relational #2929
base: 16.0
Are you sure you want to change the base?
Conversation
Hi @tarteo, |
0c3272a
to
360e8af
Compare
157eca7
to
bda41fc
Compare
@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 |
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. |
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?
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
<#2929 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAXHYV754KFAPHOFAOWWP53ZZJIXBAVCNFSM6AAAAABNWI4FPCVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDGOBVGA2TKMJTHE>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
328f853
to
eb862c9
Compare
eb862c9
to
2114bfa
Compare
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.. |
832c06a
to
1592ce8
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Functionally tested, and it works. Just a minor technical change needed for performance reasons.
const fields = await this._rpc({ | ||
model: this.modelName, | ||
method: "fields_get", | ||
args: [[grouped_field]], | ||
context: this.getSession().user_context, | ||
}); | ||
const fieldType = fields[grouped_field].type; | ||
const relation = fields[grouped_field].relation; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this RPC call can be avoided if you use this.fields
, which already contains metadata for fields (such as type, relation, etc.).
const fields = await this._rpc({ | |
model: this.modelName, | |
method: "fields_get", | |
args: [[grouped_field]], | |
context: this.getSession().user_context, | |
}); | |
const fieldType = fields[grouped_field].type; | |
const relation = fields[grouped_field].relation; | |
const fieldType = this.fields[grouped_field].type; | |
const relation = this.fields[grouped_field].relation; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you, good catch!!
1592ce8
to
44a7b0a
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
ping @pedrobaeza |
views: [[false, "form"]], | ||
}); | ||
} | ||
console.warn(`Field ${groupField} is not a relational field.`); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove this
@@ -2,7 +2,7 @@ | |||
Web timeline | |||
============ | |||
|
|||
.. | |||
.. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These changes seem to be done by the IDE stripping out leading spaces. They should be removed.
@@ -8,11 +8,10 @@ | |||
|
|||
/* | |||
:Author: David Goodger ([email protected]) | |||
:Id: $Id: html4css1.css 9511 2024-01-13 09:50:07Z milde $ | |||
:Id: $Id: html4css1.css 8954 2022-01-20 10:10:25Z milde $ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This also shouldn't change.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I dont know how that change was done, but it seems legit to me, maybe is the precommit thing..
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, because you have a different libraries than the bot, but it will be undone again by the bot. I was trying to avoid noise.
…th a relational field in addition fixes grouping when the field is not relational, and default_group_by can use a non relational field
44a7b0a
to
916e166
Compare
No description provided.