[17.0][FIX] payroll_account: Fix _get_partner_id logic in hr_payslip_line#225
Open
[17.0][FIX] payroll_account: Fix _get_partner_id logic in hr_payslip_line#225
Conversation
In Odoo 17.0+, the address_home_id field was removed from hr.employee and replaced with work_contact_id. This caused journal entries to be created without proper partner information when no register partner was configured. This fix implements proper partner resolution logic: - For asset_receivable and liability_current accounts: Use employee partner (work_contact_id with fallback to bank_account_id.partner_id) - For liability_payable accounts: Use register partner - For other account types: No partner assigned Also includes proper null checks to prevent AttributeError when accessing .id on empty Many2one fields. Added minimal test coverage for the new partner logic to verify correct partner assignment for different account types. Fixes OCA#221
Contributor
|
Hi @nimarosa, @appstogrow, |
t-saeed
approved these changes
Mar 10, 2026
Contributor
|
This PR has the |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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:
address_home_idfrom modelhr.employeewhich was used in getting partner for employee inpayroll_accountto set partner in created journal entry. Migrated code removed usage ofaddress_home_idbut did not use a replacement.liability_currentaccount type in partner-required accountsSolution
Replaced the flawed logic with semantically-correct partner assignment using the proper partner source:
Changes
Core Logic (payroll_account/models/hr_payslip_line.py)
Business Logic
Test Coverage
Added
test_partner_logic_account_types()to verify:Fixes #221
Pull Request opened by Augment Code with guidance from the PR author