[16.0][IMP] account_payment_partner: company flag to control partner_bank_id without payment mode#3
Closed
felipemotter wants to merge 2 commits into16.0from
Closed
Conversation
…thout payment mode Add a company-level setting keep_partner_bank_without_payment_mode (default True) that controls whether partner_bank_id is preserved or cleared when no payment mode is set on an invoice. When enabled (default), invoices without a payment mode keep the bank account auto-selected by Odoo core. When disabled, the bank account is cleared (legacy behavior). This resolves the long-standing disagreement in OCA#1418 by letting each company choose the behavior that fits their workflow.
b667057 to
9d65b1d
Compare
Update test_onchange_payment_mode_id to reflect the new default behavior (flag=True keeps bank account). Add test_no_payment_mode_clears_bank_when_flag_disabled to verify that disabling the flag restores the legacy clearing behavior. Add test_refund_no_payment_mode_preserves_partner_bank to verify that refunds without payment mode preserve the bank account.
9d65b1d to
aa8e643
Compare
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.
Context
This PR is a proof of concept to resolve the stalemate in the OCA/bank-payment#1418 discussion, which has been stuck for over a year.
The core issue: the
else: move.partner_bank_id = Falsein_compute_partner_bank_idunconditionally clears the bank account when no payment mode is set. This breaks Odoo core behavior (which now usesallow_out_paymentto auto-select trusted bank accounts), affecting Peppol, QR codes, Swiss localization, and l10n-brazil tests.Our PR #1555 simply removes the
else, which fixes the problem but doesn't satisfy those who depend on the legacy behavior (e.g. direct debit orders, as pointed out by @pedrobaeza).Proposed solution
The consensus solution suggested by Pedro himself in the original discussion: a company-level flag that controls which behavior to use.
New field
keep_partner_bank_without_payment_mode(Boolean) onres.company:True(default): no payment mode → keeps whateversuper()computed (new behavior, respects Odoo core)False: no payment mode → clearspartner_bank_id = False(legacy behavior)What changes in practice
Files modified
models/res_company.py(new) - Boolean field on companymodels/res_config_settings.py(new) - related field for settings UIviews/res_config_settings.xml(new) - checkbox in settingsmodels/account_move.py-elsebranch now checks the flagmodels/__init__.py- imports for new models__manifest__.py- version bump to 16.0.1.3.0Tests
test_onchange_payment_mode_idupdated to reflect the default (flag=True keeps bank)test_no_payment_mode_clears_bank_when_flag_disabled(new) - verifies flag=False clears the banktest_refund_no_payment_mode_preserves_partner_bank(new) - verifies refund without payment mode preserves the bankAll 20 tests passing, 0 failures.
Important
This PR is a proof of concept only. The goal is to validate the approach before formally proposing it on OCA/bank-payment. It should not be merged directly — the idea is to use it as the basis for a new upstream PR replacing OCA#1555, if the approach is approved.