← Back to Pull requests

[18.0][FIX] payroll_account: Fix _get_partner_id logic in hr_payslip_line #226

Closed
unknown closed this pull request without merging on May 04, 2026 08:17 UTC
View on GitHub
unknown unknown commented on Oct 16, 2025 12:14 UTC
Author

Description


This PR fixes the partner logic in hr_payslip_line._get_partner_id() to address issue #221 where journal entries were created without proper partner information in Odoo 17.0+.

Problem


The original logic had several issues:

1. Odoo removed field address_home_id from model hr.employee which was used in getting partner for employee in payroll_account to set partner in created journal entry. Migrated code removed usage of address_home_id but did not use a replacement.
2. Old code (16.0 and earlier) used a confusing fallback chain that could potentially assign wrong partners
3. Missing liability_current account type in partner-required accounts

Solution


Replaced the flawed logic with semantically-correct partner assignment using the proper partner source:

  • asset_receivable & liability_current: Always use employee partner (work_contact_id → bank_account_id.partner_id)

  • liability_payable: Always use register partner (salary_rule_id.register_id.partner_id)

  • Other account types (expense, income, etc.): No partner assigned
  • Changes

    Core Logic (payroll_account/models/hr_payslip_line.py)

  • Simplified logic from confusing fallback to clear semantic rules

  • Added liability_current to partner-required account types

  • Enhanced documentation with business semantics and partner sources

  • Replaced if register_partner_id or acc_type in (...) with proper if elif structure
  • Business Logic

    | Account Type | Business Use | Partner Source |
    |---|---|---|
    | asset_receivable | Employee loans, advances | Employee |
    | liability_current | Employee salary payable | Employee |
    | liability_payable | Tax authorities, insurance | Register Partner |
    | expense, income, etc. | Internal accounting | No Partner |

    Test Coverage

    Added test_partner_logic_account_types() to verify:

  • asset_receivable accounts return employee partner

  • liability_current accounts return employee partner

  • liability_payable accounts return register partner

  • Other account types return False (no partner)
  • Fixes #221

    ---
    Pull Request opened by Augment Code with guidance from the PR author

    Diff: 276 lines (+207 / -69) across 3 files Reviewer: nimarosa Review duration: 287763m
    All Vouch review confidence checks passed
    Residual risk 0.25 = Change Risk (0.63) × (1 − Review Confidence (0.60)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.63 · 276 lines diff across 3 files
    0.63
    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.336
    Shallow Review Depth shallow_review_depth
    0.289
    Sensitive Paths sensitive_paths
    0.063
    Real PR Conversation Timeline
    1 comments
    "Review active on #226"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 60.5% reviewed sensitive_module
    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: 62.7% (MEDIUM) · Higher = larger blast radius
    62.7%
    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: 24.8% · Safe to merge
    24.8%
    Repository