Skip to content

Conversation

@xaviedoanhduy
Copy link
Contributor

@xaviedoanhduy xaviedoanhduy commented Dec 12, 2025

Problem: In _prepare_move_line_default_vals, there is a filter designed to remove empty move lines (where both debit and credit are 0). However, upstream code sometimes generates write-off lines containing only a balance key (see), missing explicit debit or credit keys. In such cases, vals['debit'] and vals['credit'] returns 0.0, causing the filter to incorrectly identify these valid lines as empty and drop them or raising an error:

File ".../account_payment_line/models/account_payment.py", line 130, in _prepare_move_line_default_vals
    if not (vals["debit"] == 0.0 and vals["credit"] == 0.0)
KeyError: 'debit'

Solution: Update the filtering condition to include the balance key. A line is now considered empty and removed only if debit, credit, AND balance are all zero. This approach preserves valid write-off lines (which have a non-zero balance) without needing to mutate the input vals_list.

@OCA-git-bot
Copy link
Contributor

Hi @ChrisOForgeFlow,
some modules you are maintaining are being modified, check this out!

@OCA-git-bot
Copy link
Contributor

Hi @ChrisOForgeFlow,
some modules you are maintaining are being modified, check this out!

@xaviedoanhduy xaviedoanhduy force-pushed the 18.0-fix-account_payment_line branch from 2e7c704 to 1d0465c Compare December 17, 2025 01:59
@xaviedoanhduy xaviedoanhduy changed the title [18.0][FIX] account_payment_line: handle missing debit/credit keys in write-off lines [18.0][FIX] account_payment: prevent filtering valid write-off lines with balance only Dec 17, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants