Skip to content

Commit c30bf4b

Browse files
author
Milan Topuzov
committed
tests: use Command API for m2m
1 parent f947199 commit c30bf4b

File tree

4 files changed

+19
-18
lines changed

4 files changed

+19
-18
lines changed

queue_job/models/queue_job.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -222,15 +222,13 @@ def _dependency_graph_vis_node(self):
222222
}
223223

224224
def _compute_graph_jobs_count(self):
225-
# Use _read_group (read_group is deprecated in Odoo 19)
226225
graph_uuids = [uuid for uuid in self.mapped("graph_uuid") if uuid]
227226
if graph_uuids:
228227
rows = self.env["queue.job"]._read_group(
229228
[("graph_uuid", "in", graph_uuids)],
230229
["graph_uuid"],
231230
["__count"],
232231
)
233-
# rows are tuples of (graph_uuid, count)
234232
count_per_graph_uuid = {graph_uuid: cnt for graph_uuid, cnt in rows}
235233
else:
236234
count_per_graph_uuid = {}

queue_job/tests/test_json_field.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
from lxml import etree
88

99
from odoo.tests import common
10+
from odoo import Command
1011

1112
# pylint: disable=odoo-addons-relative-import
1213
# we are testing, we want to test as we were an external consumer of the API
@@ -25,8 +26,8 @@ def setUpClass(cls):
2526
"name": "Demo User (Queue)",
2627
"login": "queue_demo_user",
2728
"company_id": main_company.id,
28-
"company_ids": [(6, 0, [main_company.id])],
29-
"group_ids": [(6, 0, [group_user.id])],
29+
"company_ids": [Command.set([main_company.id])],
30+
"group_ids": [Command.set([group_user.id])],
3031
}
3132
)
3233

test_queue_job/tests/test_job.py

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import odoo.tests.common as common
99

1010
from odoo.addons.queue_job import identity_exact
11+
from odoo import Command
1112
from odoo.addons.queue_job.delay import DelayableGraph
1213
from odoo.addons.queue_job.exception import (
1314
FailedJobError,
@@ -43,8 +44,8 @@ def setUpClass(cls):
4344
"name": "Demo User (Queue)",
4445
"login": "queue_demo_user_3",
4546
"company_id": main_company.id,
46-
"company_ids": [(6, 0, [main_company.id])],
47-
"group_ids": [(6, 0, [group_user.id])],
47+
"company_ids": [Command.set([main_company.id])],
48+
"group_ids": [Command.set([group_user.id])],
4849
}
4950
)
5051

@@ -414,8 +415,8 @@ def setUpClass(cls):
414415
"name": "Demo User (Queue)",
415416
"login": "queue_demo_user_4",
416417
"company_id": main_company.id,
417-
"company_ids": [(6, 0, [main_company.id])],
418-
"group_ids": [(6, 0, [group_user.id])],
418+
"company_ids": [Command.set([main_company.id])],
419+
"group_ids": [Command.set([group_user.id])],
419420
}
420421
)
421422

@@ -554,8 +555,8 @@ def setUpClass(cls):
554555
"name": "Demo User (Queue)",
555556
"login": "queue_demo_user_5",
556557
"company_id": main_company.id,
557-
"company_ids": [(6, 0, [main_company.id])],
558-
"group_ids": [(6, 0, [group_user.id])],
558+
"company_ids": [Command.set([main_company.id])],
559+
"group_ids": [Command.set([group_user.id])],
559560
}
560561
)
561562

@@ -652,7 +653,7 @@ def test_follower_when_write_fail(self):
652653
vals = {
653654
"name": "xx",
654655
"login": "xx",
655-
"group_ids": [(6, 0, [group.id])],
656+
"group_ids": [Command.set([group.id])],
656657
"active": False,
657658
}
658659
inactiveusr = self.user.create(vals)
@@ -711,7 +712,7 @@ def setUp(self):
711712
self.simple_user = User.create(
712713
{
713714
"partner_id": self.partner_user.id,
714-
"company_ids": [(4, main_company.id)],
715+
"company_ids": [Command.link(main_company.id)],
715716
"login": "simple_user",
716717
"name": "simple user",
717718
"group_ids": [],
@@ -732,10 +733,10 @@ def setUp(self):
732733
{
733734
"partner_id": self.other_partner_a.id,
734735
"company_id": self.other_company_a.id,
735-
"company_ids": [(4, self.other_company_a.id)],
736+
"company_ids": [Command.link(self.other_company_a.id)],
736737
"login": "my_login a",
737738
"name": "my user A",
738-
"group_ids": [(4, grp_queue_job_manager)],
739+
"group_ids": [Command.link(grp_queue_job_manager)],
739740
}
740741
)
741742
self.other_partner_b = Partner.create(
@@ -752,10 +753,10 @@ def setUp(self):
752753
{
753754
"partner_id": self.other_partner_b.id,
754755
"company_id": self.other_company_b.id,
755-
"company_ids": [(4, self.other_company_b.id)],
756+
"company_ids": [Command.link(self.other_company_b.id)],
756757
"login": "my_login_b",
757758
"name": "my user B",
758-
"group_ids": [(4, grp_queue_job_manager)],
759+
"group_ids": [Command.link(grp_queue_job_manager)],
759760
}
760761
)
761762

test_queue_job/tests/test_json_field.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import json
55

66
from odoo.tests import common
7+
from odoo import Command
78

89
# pylint: disable=odoo-addons-relative-import
910
# we are testing, we want to test as if we were an external consumer of the API
@@ -22,8 +23,8 @@ def setUpClass(cls):
2223
"name": "Demo User (Queue)",
2324
"login": "queue_demo_user_2",
2425
"company_id": main_company.id,
25-
"company_ids": [(6, 0, [main_company.id])],
26-
"group_ids": [(6, 0, [group_user.id])],
26+
"company_ids": [Command.set([main_company.id])],
27+
"group_ids": [Command.set([group_user.id])],
2728
}
2829
)
2930

0 commit comments

Comments
 (0)