← Back to Pull requests

[FIX] partner_multi_relation: make this_partner_id/other_partner_id searchable #2425

Closed
unknown closed this pull request without merging on Aug 28, 2026 14:09 UTC
View on GitHub
unknown unknown commented on Aug 25, 2026 19:52 UTC
Author

Problem

Odoo 19 warns when a computed field's @depends chain crosses a non-stored
field that has no search method, because it cannot determine which records to
recompute when the dependency changes (odoo/orm/fields.py, resolve_depends):

Field <field> in dependency of <field> should be searchable. This is necessary
to determine which records to recompute when <field> is modified. You should
either make the field searchable, or simplify the field dependency.

this_partner_id and other_partner_id are computed, non-stored and declare
no search=. Any module defining a field related="this_partner_id.<x>" (or
on other_partner_id) raises that warning on every registry setup — and, more
importantly, the related field is left without a reliable recompute trigger
when the underlying partner value changes.

Why not simplify the dependency

Both fields resolve to whichever of left_partner_id / right_partner_id
matches the current_partner_id context
(_compute_this_partner_id / _compute_other_partner_id), so there is no
context-free column to search recompute candidates against. They genuinely need
a search method.

Fix

Each field gets its own search method mirroring its compute, side by side:

def _search_this_partner_id(self, operator, value):
    current_partner = self._get_current_partner()
    if not current_partner:
        return [("left_partner_id", operator, value)]
    return [
        "|",
        "&", ("right_partner_id", "=", current_partner.id),
             ("right_partner_id", operator, value),
        "&", ("right_partner_id", "!=", current_partner.id),
             ("left_partner_id", operator, value),
    ]

and the inverse pairing for _search_other_partner_id. Without a current
partner the domain collapses to the single side the compute falls back to.

The first version of this PR reused _search_any_partner_id for both fields.
Review
correctly pointed out that it does not match the computes: it matches a partner
on either side, while each compute resolves to exactly one side.
Searching this_partner_id = X returned relations whose computed
this_partner_id is a different partner, and with current_partner_id in
context every result could be a false positive.

A cache bug the tests exposed

_get_current_partner() falls back to active_model / active_id, but the
computes only declared @api.depends_context("current_partner_id"): a value
computed without context was reused verbatim in an active_id context, so the
compute disagreed with itself depending on which context filled the cache
first. The computes now declare the two extra context keys, plus the
@api.depends("left_partner_id", "right_partner_id") that was missing for
writes to invalidate the cached aliases.

Tests

test_search_this_other_partner_matches_compute asserts search and compute
agree record by record for both fields across the four context shapes: no
context, current partner on the left, current partner on the right, and
active_model/active_id. test_search_this_other_partner_by_name covers a
non-equality operator (ilike) through the same side-aware domain.

Full module suite on a clean 19.0 database: 0 failures.

Reproducing the original warning

Declare on any model a field related="this_partner_id.<something>" over
res.partner.relation and start the server: the warning is emitted once per
registry setup.

Diff: 440 lines (+330 / -110) across 5 files Reviewer: NL66278 Review duration: 3977m
All Vouch review confidence checks passed
Residual risk 0.18 = Change Risk (0.45) × (1 − Review Confidence (0.60)). Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.45 · 440 lines diff across 5 files
0.45
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.17 · 1 substantive comment(s)
0.17
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
60%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size diff_size
0.364
Shallow Review Depth shallow_review_depth
0.289
Real PR Conversation Timeline
1 comments
"Review active on #2425"
general weight: 0.35
Reviewers
Assignees
Unassigned
Labels
risk: low confidence: 60.5% reviewed
Vouch Risk Breakdown
AI-powered review risk analysis
Change Risk
Change Risk · Model 1 (XGBoost)
Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
Score: 45.3% (MEDIUM) · Higher = larger blast radius
45.3%
Review Confidence
Review Confidence · Models 2 & 3
Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
Score: 60.5% · Lower = rushed or shallow review
60.5%
Residual Risk
Residual Risk · Core Equation
Residual = Change × (1 − Confidence)
Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
Score: 17.9% · Safe to merge
17.9%