Skip to content

Commit

Permalink
[IMP] queue_job_batch: inverse batch order
Browse files Browse the repository at this point in the history
This make latest created batch on top of notification list
  • Loading branch information
petrus-v committed Sep 17, 2024
1 parent 28460c6 commit 793f06e
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 0 deletions.
1 change: 1 addition & 0 deletions queue_job_batch/models/queue_job_batch.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ class QueueJobBatch(models.Model):
_inherit = ["mail.thread", "mail.activity.mixin"]
_description = "Batch of jobs"
_log_access = False
_order = "id desc"

name = fields.Char(
required=True,
Expand Down
1 change: 1 addition & 0 deletions queue_job_batch/tests/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import test_queue_job_batch
17 changes: 17 additions & 0 deletions queue_job_batch/tests/test_queue_job_batch.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
from odoo.tests import SavepointCase


class TestQueueJobBatch(SavepointCase):
@classmethod
def setUpClass(cls):
super().setUpClass()
cls.batch1 = cls.env["queue.job.batch"].get_new_batch("batch 1")
cls.batch2 = cls.env["queue.job.batch"].get_new_batch("batch 2")

def test_default_order(self):
"""we want latest batch on top of the notification list"""
batches = self.env["queue.job.batch"].search(
[("id", "in", (self.batch1 | self.batch2).ids)]
)
self.assertEqual(batches[0].name, "batch 2")
self.assertEqual(batches[1].name, "batch 1")

0 comments on commit 793f06e

Please sign in to comment.