3636 way to ``spp.vocabulary.code``. So callers must pass display strings.
3737"""
3838
39- from datetime import datetime , timedelta
40-
41- from odoo import fields
4239from odoo .tests import tagged
4340
4441from .common import RegistryCommon
@@ -49,17 +46,11 @@ class AggregationCommon(RegistryCommon):
4946 @classmethod
5047 def setUpClass (cls ):
5148 super ().setUpClass ()
52- cls .individual_c = cls .Partner .create (
53- {"name" : "Carol" , "is_registrant" : True , "is_group" : False }
54- )
55- cls .individual_d = cls .Partner .create (
56- {"name" : "Dave" , "is_registrant" : True , "is_group" : False }
57- )
49+ cls .individual_c = cls .Partner .create ({"name" : "Carol" , "is_registrant" : True , "is_group" : False })
50+ cls .individual_d = cls .Partner .create ({"name" : "Dave" , "is_registrant" : True , "is_group" : False })
5851
5952 # Second group so multi-group queries can be tested.
60- cls .group_b = cls .Partner .create (
61- {"name" : "Second Household" , "is_registrant" : True , "is_group" : True }
62- )
53+ cls .group_b = cls .Partner .create ({"name" : "Second Household" , "is_registrant" : True , "is_group" : True })
6354
6455 # Synthesize a non-head membership-type code so we can filter
6556 # by relationship_kinds without head-uniqueness collisions.
@@ -81,9 +72,7 @@ def _add_member(self, group, individual, type_codes=()):
8172 {
8273 "group" : group .id ,
8374 "individual" : individual .id ,
84- "membership_type_ids" : [(6 , 0 , [c .id for c in type_codes ])]
85- if type_codes
86- else False ,
75+ "membership_type_ids" : [(6 , 0 , [c .id for c in type_codes ])] if type_codes else False ,
8776 }
8877 )
8978
@@ -146,10 +135,7 @@ def test_disabled_individual_excluded(self):
146135 ``_query_members_aggregate`` from ``expression.expression()`` to
147136 the ``Domain`` API (the deprecation warning's own suggestion).
148137 Then drop these skips."""
149- self .skipTest (
150- "BROKEN: deprecated expression.expression() yields empty "
151- "filter SQL on Odoo 19 — see docstring"
152- )
138+ self .skipTest ("BROKEN: deprecated expression.expression() yields empty filter SQL on Odoo 19 — see docstring" )
153139
154140 def test_ended_membership_excluded (self ):
155141 """Same Odoo-19 ``expression.expression()`` deprecation bug as
@@ -186,26 +172,20 @@ class TestCountIndividualsKindFilter(AggregationCommon):
186172 def test_filter_by_head_display_matches_only_head_members (self ):
187173 self ._add_member (self .group , self .individual_a , type_codes = [self .head_code ])
188174 self ._add_member (self .group , self .individual_b , type_codes = [self .member_code ])
189- result = self ._to_dict (
190- self .group .count_individuals (relationship_kinds = ["Head" ])
191- )
175+ result = self ._to_dict (self .group .count_individuals (relationship_kinds = ["Head" ]))
192176 self .assertEqual (result .get (self .group .id ), 1 )
193177
194178 def test_filter_by_multiple_displays (self ):
195179 self ._add_member (self .group , self .individual_a , type_codes = [self .head_code ])
196180 self ._add_member (self .group , self .individual_b , type_codes = [self .member_code ])
197- result = self ._to_dict (
198- self .group .count_individuals (relationship_kinds = ["Head" , "Member" ])
199- )
181+ result = self ._to_dict (self .group .count_individuals (relationship_kinds = ["Head" , "Member" ]))
200182 self .assertEqual (result .get (self .group .id ), 2 )
201183
202184 def test_filter_with_no_matches_returns_no_row (self ):
203185 """No memberships with the requested kind → group falls out of
204186 the GROUP BY entirely."""
205187 self ._add_member (self .group , self .individual_a , type_codes = [self .head_code ])
206- result = self ._to_dict (
207- self .group .count_individuals (relationship_kinds = ["Member" ])
208- )
188+ result = self ._to_dict (self .group .count_individuals (relationship_kinds = ["Member" ]))
209189 self .assertNotIn (self .group .id , result )
210190
211191 def test_lowercase_code_does_not_match (self ):
@@ -215,9 +195,7 @@ def test_lowercase_code_does_not_match(self):
215195
216196 Pin the surprise; document until the impl is harmonized."""
217197 self ._add_member (self .group , self .individual_a , type_codes = [self .head_code ])
218- result = self ._to_dict (
219- self .group .count_individuals (relationship_kinds = ["head" ])
220- )
198+ result = self ._to_dict (self .group .count_individuals (relationship_kinds = ["head" ]))
221199 self .assertNotIn (self .group .id , result )
222200
223201
@@ -229,16 +207,12 @@ class TestCountIndividualsDomainFilter(AggregationCommon):
229207 def test_filter_by_individual_name (self ):
230208 self ._add_member (self .group , self .individual_a ) # "Alice"
231209 self ._add_member (self .group , self .individual_b ) # "Bob"
232- result = self ._to_dict (
233- self .group .count_individuals (domain = [("name" , "=" , "Alice" )])
234- )
210+ result = self ._to_dict (self .group .count_individuals (domain = [("name" , "=" , "Alice" )]))
235211 self .assertEqual (result .get (self .group .id ), 1 )
236212
237213 def test_filter_with_no_matching_individuals (self ):
238214 self ._add_member (self .group , self .individual_a )
239- result = self ._to_dict (
240- self .group .count_individuals (domain = [("name" , "=" , "Nobody" )])
241- )
215+ result = self ._to_dict (self .group .count_individuals (domain = [("name" , "=" , "Nobody" )]))
242216 self .assertNotIn (self .group .id , result )
243217
244218 def test_compound_domain (self ):
@@ -247,9 +221,7 @@ def test_compound_domain(self):
247221 self ._add_member (self .group , self .individual_b ) # Bob, individual
248222 # All individuals match is_registrant=True; restrict to "Alice".
249223 result = self ._to_dict (
250- self .group .count_individuals (
251- domain = [("is_registrant" , "=" , True ), ("name" , "=" , "Alice" )]
252- )
224+ self .group .count_individuals (domain = [("is_registrant" , "=" , True ), ("name" , "=" , "Alice" )])
253225 )
254226 self .assertEqual (result .get (self .group .id ), 1 )
255227
@@ -259,9 +231,7 @@ def test_kind_and_domain_combined(self):
259231 self ._add_member (self .group , self .individual_b , type_codes = [self .member_code ])
260232 # Only Bob is a "Member" AND named "Bob" → expect 1.
261233 result = self ._to_dict (
262- self .group .count_individuals (
263- relationship_kinds = ["Member" ], domain = [("name" , "=" , "Bob" )]
264- )
234+ self .group .count_individuals (relationship_kinds = ["Member" ], domain = [("name" , "=" , "Bob" )])
265235 )
266236 self .assertEqual (result .get (self .group .id ), 1 )
267237
@@ -297,11 +267,7 @@ def test_kind_domain_with_translated_name_leaf(self):
297267 op, val)`` for the vocab query. Pin that the translation is the
298268 contract — pass a ``name`` leaf and observe display filtering."""
299269 self ._add_member (self .group , self .individual_a , type_codes = [self .head_code ])
300- result = dict (
301- self .group ._query_members_aggregate (
302- membership_kind_domain = [("name" , "in" , ["Head" ])]
303- )
304- )
270+ result = dict (self .group ._query_members_aggregate (membership_kind_domain = [("name" , "in" , ["Head" ])]))
305271 self .assertEqual (result .get (self .group .id ), 1 )
306272
307273
@@ -339,9 +305,7 @@ def test_no_records_is_noop(self):
339305 # Pass only individuals; ``.filtered(lambda a: a.is_group)`` yields
340306 # empty. Method should silently return.
341307 individuals = self .individual_a | self .individual_b
342- individuals .compute_count_and_set_indicator (
343- field_name = "never_set" , kinds = None , domain = None
344- )
308+ individuals .compute_count_and_set_indicator (field_name = "never_set" , kinds = None , domain = None )
345309
346310
347311@tagged ("post_install" , "-at_install" )
@@ -353,9 +317,7 @@ class TestUpdateComputeFields(AggregationCommon):
353317 def test_filters_to_groups_only_no_raise (self ):
354318 """Non-group records are filtered out by the first line."""
355319 individuals = self .individual_a | self .individual_b
356- self .env ["res.partner" ]._update_compute_fields (
357- individuals , field_name = "never_set" , kinds = None , domain = None
358- )
320+ self .env ["res.partner" ]._update_compute_fields (individuals , field_name = "never_set" , kinds = None , domain = None )
359321
360322 def test_happy_path_requires_host_module_field (self ):
361323 # TODO: same as TestComputeCountAndSetIndicator — needs an integer
0 commit comments