Conversation
Models that have an "_order" parameter are not configured correctly. Setting only field that are not unique in the "_order" attribute is not correct. When using "order" key of the "search" function, Odoo uses the "_order" attribute of the object to order element. If there is several element with the same value for the key in "_order" than Odoo will treat them as equal and will not sort them. This leads to errors in the portal of the shifts because shifts are note aggregated correctly by template.
968604d to
451f831
Compare
huguesdk
left a comment
There was a problem hiding this comment.
i’m not sure i understand: is the problem due to the fact that the order of records that have the same value for the field used in _order is different from time to time, and you want to ensure that it always stays the same? are you using id to have an extra value meaning “creation order”? i think that the commit message should be more explicit about the “why”, because i think that this sentence is not correct:
Setting only field that are not unique in the "_order" attribute is not correct.
or maybe i am missing something?
| _name = "shift.template" | ||
| _description = "shift.template" | ||
| _order = "start_time" | ||
| _order = "planning_id, task_type_id, start_time, id" |
There was a problem hiding this comment.
is it intentional to heavily change the order here?
There was a problem hiding this comment.
Yes, it is intentional. Ordering by "start_time" (knowing that start time is only a float value representing hours) has no sens.
Description
Models that have an "_order" parameter are not configured correctly.
Setting only fields that are not unique in the "_order" attribute is not correct.
When using "order" key of the "search" function, Odoo uses the "_order" attribute of the object to order element. If there is several element with the same value for the key in "_order" than Odoo will treat them as equal and will not sort them.
This leads to errors in the portal of the shifts because shifts are note aggregated correctly by template.
Odoo task (if applicable)
task
Checklist before approval