Skip to content

Commit 968604d

Browse files
committed
[FIX] shift: ordering
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.
1 parent 6f40b71 commit 968604d

3 files changed

Lines changed: 5 additions & 5 deletions

File tree

shift/models/cooperative_status.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ class HistoryStatus(models.Model):
2525
_name = "cooperative.status.history"
2626
_description = "cooperative.status.history"
2727

28-
_order = "create_date desc"
28+
_order = "create_date desc, id"
2929

3030
status_id = fields.Many2one("cooperative.status")
3131
cooperator_id = fields.Many2one("res.partner")

shift/models/planning.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ class ShiftDayNumber(models.Model):
4040
_name = "shift.daynumber"
4141
_description = "shift.daynumber"
4242

43-
_order = "number asc"
43+
_order = "number asc, id"
4444

4545
name = fields.Char()
4646
number = fields.Integer(
@@ -55,7 +55,7 @@ class ShiftDayNumber(models.Model):
5555
class ShiftPlanning(models.Model):
5656
_name = "shift.planning"
5757
_description = "shift.planning"
58-
_order = "sequence asc"
58+
_order = "sequence asc, id"
5959

6060
sequence = fields.Integer()
6161
name = fields.Char()
@@ -198,7 +198,7 @@ def get_future_shifts(
198198
class ShiftTemplate(models.Model):
199199
_name = "shift.template"
200200
_description = "shift.template"
201-
_order = "start_time"
201+
_order = "planning_id, task_type_id, start_time, id"
202202

203203
name = fields.Char(required=True)
204204
planning_id = fields.Many2one("shift.planning", required=True)

shift/models/shift_shift.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
class ShiftShift(models.Model):
1111
_name = "shift.shift"
1212
_inherit = ["mail.thread"]
13-
_order = "start_time asc"
13+
_order = "start_time asc, task_template_id, task_type_id, worker_id, id"
1414

1515
##################################
1616
# Method to override #

0 commit comments

Comments
 (0)