Skip to content

Commit 9d970a6

Browse files
committed
fix(spp_program_geofence): fix spatial query operator and test compatibility
- Use gis_intersects instead of gis_within for Tier 1 spatial query; gis_within generates ST_Within(value, field) which is backwards for point-in-polygon checks, while gis_intersects is symmetric - Use disabled=None instead of disabled=False in domain (Datetime field) - Use fields.Datetime.now() for disabled test data (not Boolean True) - Use group_ids with Command.link() for Odoo 19 compatibility in tests
1 parent 535c5a4 commit 9d970a6

2 files changed

Lines changed: 8 additions & 13 deletions

File tree

spp_program_geofence/models/eligibility_manager.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -108,8 +108,8 @@ def _prepare_eligible_domain(self, membership=None):
108108
ids = membership.mapped("partner_id.id")
109109
domain += [("id", "in", ids)]
110110

111-
# Exclude disabled registrants
112-
domain += [("disabled", "=", False)]
111+
# Exclude disabled registrants (disabled is a Datetime field)
112+
domain += [("disabled", "=", None)]
113113

114114
if self.program_id.target_type == "group":
115115
domain += [("is_group", "=", True), ("is_registrant", "=", True)]
@@ -145,7 +145,7 @@ def _find_eligible_registrants(self, membership=None):
145145
base_domain = self._prepare_eligible_domain(membership)
146146

147147
# Tier 1: registrants with coordinates inside the geofence
148-
tier1_domain = base_domain + [("coordinates", "gis_within", combined_geojson)]
148+
tier1_domain = base_domain + [("coordinates", "gis_intersects", combined_geojson)]
149149
tier1 = self.env["res.partner"].search(tier1_domain)
150150

151151
# Tier 2: registrants whose area intersects the geofence

spp_program_geofence/tests/test_geofence_eligibility.py

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
import json
55

6+
from odoo import Command, fields
67
from odoo.tests import TransactionCase, tagged
78

89

@@ -148,7 +149,7 @@ def setUpClass(cls):
148149
"name": "Disabled Registrant",
149150
"is_registrant": True,
150151
"is_group": False,
151-
"disabled": True,
152+
"disabled": fields.Datetime.now(),
152153
"coordinates": point_inside,
153154
}
154155
)
@@ -402,15 +403,9 @@ def setUpClass(cls):
402403
{
403404
"name": "Test Officer",
404405
"login": "test_geofence_officer",
405-
"groups_id": [
406-
(
407-
6,
408-
0,
409-
[
410-
cls.env.ref("spp_programs.group_programs_officer").id,
411-
cls.env.ref("base.group_user").id,
412-
],
413-
)
406+
"group_ids": [
407+
Command.link(cls.env.ref("spp_programs.group_programs_officer").id),
408+
Command.link(cls.env.ref("base.group_user").id),
414409
],
415410
}
416411
)

0 commit comments

Comments
 (0)