Skip to content

[12.0] [FIX] shift: ordering#581

Open
remytms wants to merge 1 commit into12.0from
12.0-fix-shift_template_ordering
Open

[12.0] [FIX] shift: ordering#581
remytms wants to merge 1 commit into12.0from
12.0-fix-shift_template_ordering

Conversation

@remytms
Copy link
Collaborator

@remytms remytms commented Mar 5, 2026

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

  • Tests are present (or not needed).
  • Credits/copyright have been changed correctly.
  • Change log snippet is present.
  • (If a new module) Moving this to OCA has been considered.

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.
@remytms remytms force-pushed the 12.0-fix-shift_template_ordering branch from 968604d to 451f831 Compare March 5, 2026 16:33
Copy link
Member

@huguesdk huguesdk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is it intentional to heavily change the order here?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, it is intentional. Ordering by "start_time" (knowing that start time is only a float value representing hours) has no sens.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants