Skip to content

Commit de69ff2

Browse files
committed
refactor(spp_programs,spp_change_request_v2): remove dead _prepare_domain overrides (OP#989)
Round-2 replaced the Python search_read / web_search_read overrides with ir.rule records that filter every ORM read path (search, count, read_group, name_search, related-field traversal). The earlier Python hooks were left in place by mistake — they only caught two of those paths and are now strictly redundant given the rule does more. Drop the dead code. Behaviour is unchanged (ir.rule still scopes the same reads). Reduces the codecov/patch denominator since the removed lines were never executed under area-restricted users.
1 parent e3ce3cd commit de69ff2

2 files changed

Lines changed: 0 additions & 70 deletions

File tree

spp_change_request_v2/models/change_request.py

Lines changed: 0 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1652,38 +1652,3 @@ def action_goto_review(self):
16521652
},
16531653
},
16541654
}
1655-
1656-
# ─── Area-based filtering (OP#989) ──────────────────────────────────
1657-
# Mirrors the `_prepare_domain` pattern from
1658-
# spp_area/models/registrant.py so a user with a local role (i.e.
1659-
# `center_area_ids` set on res.users by spp_area) only sees change
1660-
# requests whose registrant is in one of their assigned areas (or
1661-
# any descendant). Users without center areas (global roles) get
1662-
# no extra filter — same as before. Without this override the CR
1663-
# list and review screens ignored center-area boundaries even
1664-
# though the registrant filter on res.partner respected them.
1665-
1666-
@api.model
1667-
def _prepare_domain(self, domain):
1668-
domain = domain or []
1669-
user = self.env.user
1670-
# Guard for installs without spp_area — the field would not
1671-
# exist on res.users in that case. spp_change_request_v2 does
1672-
# not yet hard-depend on spp_area, so the guard keeps this
1673-
# override safe even when spp_area isn't loaded.
1674-
center_area_ids = getattr(user, "center_area_ids", None)
1675-
if center_area_ids:
1676-
domain = list(domain) + [
1677-
("registrant_id.area_id", "child_of", center_area_ids.ids),
1678-
]
1679-
return domain
1680-
1681-
@api.model
1682-
def search_read(self, domain=None, fields=None, offset=0, limit=None, order=None):
1683-
domain = self._prepare_domain(domain)
1684-
return super().search_read(domain, fields, offset, limit, order)
1685-
1686-
@api.model
1687-
def web_search_read(self, domain, specification, offset=0, limit=None, order=None, count_limit=None):
1688-
domain = self._prepare_domain(domain)
1689-
return super().web_search_read(domain, specification, offset, limit, order, count_limit)

spp_programs/models/program_membership.py

Lines changed: 0 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -496,38 +496,3 @@ def _bulk_insert_on_conflict(self, vals_list, chunk_size=1000):
496496
len(vals_list) - total_inserted,
497497
)
498498
return total_inserted
499-
500-
# ─── Area-based filtering (OP#989) ──────────────────────────────────
501-
# Mirrors the `_prepare_domain` pattern from
502-
# spp_area/models/registrant.py so a user with a local role (i.e.
503-
# `center_area_ids` set on res.users by spp_area) only sees program
504-
# memberships whose partner is in one of their assigned areas (or
505-
# any descendant of those areas). Users without center areas
506-
# (global roles) get no extra filter — they see everything as
507-
# before. Without this override "Verify Eligibility" / "Enroll
508-
# Eligible" / the membership list bypassed area boundaries entirely.
509-
510-
@api.model
511-
def _prepare_domain(self, domain):
512-
domain = domain or []
513-
user = self.env.user
514-
# Guard against installs where spp_area isn't loaded — the
515-
# field would not exist on res.users in that case. spp_programs
516-
# already depends on spp_area today, but the guard keeps this
517-
# override behaving sensibly if that ever changes.
518-
center_area_ids = getattr(user, "center_area_ids", None)
519-
if center_area_ids:
520-
domain = list(domain) + [
521-
("partner_id.area_id", "child_of", center_area_ids.ids),
522-
]
523-
return domain
524-
525-
@api.model
526-
def search_read(self, domain=None, fields=None, offset=0, limit=None, order=None):
527-
domain = self._prepare_domain(domain)
528-
return super().search_read(domain, fields, offset, limit, order)
529-
530-
@api.model
531-
def web_search_read(self, domain, specification, offset=0, limit=None, order=None, count_limit=None):
532-
domain = self._prepare_domain(domain)
533-
return super().web_search_read(domain, specification, offset, limit, order, count_limit)

0 commit comments

Comments
 (0)