← Back to Pull requests

[19.0][FIX] partner_company_default: don't stomp an explicit company assignment #2401

Open
unknown opened this pull request with 246 lines diff across 3 files
View on GitHub
unknown unknown commented on Jul 02, 2026 19:24 UTC
Author

Problem

The default on company_id is applied whenever the key is missing from the create() values, even when the company is being assigned some other way.

This composes badly with OCA's base_multi_company (multi-company repo), where company_id becomes a computed field whose inverse replaces the real company_ids:

  • Production: create({"name": "X", "company_ids": [(6, 0, [company_b.id])]}) silently ends up with company_ids = [active company] — the explicit assignment is stomped by the default's inverse. Easy to hit from imports or RPC.

  • Under test_enable: the guard's False return still counts as an assigned value, fires the inverse, and wipes company_ids entirely — making several partner_multi_company tests fail whenever both modules are installed in the same test run.
  • Reproduction (production conditions, both modules installed):

    partner = env["res.partner"].create({"name": "P", "company_ids": [Command.set(co_a.ids)]})
    partner.company_ids  # -> [active company], not [co_a]
    

    Fix

    Replace the field default with a create() override that only fills the company in when no company information was provided at all (neither company_id nor company_ids in the values — a plain dict check, so no dependency on the multi-company modules).

    Standalone behaviour is unchanged:

  • partners created without a company still get the active company,

  • a company's own partner stays global (creating_from_company guard),

  • the test-mode guard keeps working.
  • An explicit company — either company_id or a multi-company company_ids — is now always respected.

    Testing

  • Module's own tests green standalone on vanilla Odoo 19 (including a new regression test for an explicit company_id).

  • Verified in combination with base_multi_company/partner_multi_company: explicit company_ids preserved, defaulting still applies when nothing is passed, and the previously failing combined test runs go green.
  • Diff: 246 lines (+184 / -62) across 3 files Reviewer: luisDIXMIT Review duration: 195738m
    All Vouch review confidence checks passed
    Residual risk 0.25 = Change Risk (0.46) × (1 − Review Confidence (0.45)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.46 · 246 lines diff across 3 files
    0.46
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.02 · 1 substantive comment(s)
    0.02
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    44%
    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
    Shallow Review Depth shallow_review_depth
    0.344
    Diff Size diff_size
    0.330
    Real PR Conversation Timeline
    1 comments
    "Review active on #2401"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 44.7% 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.9% (MEDIUM) · Higher = larger blast radius
    45.9%
    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: 44.7% · Lower = rushed or shallow review
    44.7%
    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: 25.4% · Safe to merge
    25.4%