Skip to content

[FIX] account_payment_partner: keep the default value for partner_bank_id#1418

Closed
sbidoul wants to merge 1 commit intoOCA:16.0from
acsone:16.0-fix-compute_partner_bank_id-sbi
Closed

[FIX] account_payment_partner: keep the default value for partner_bank_id#1418
sbidoul wants to merge 1 commit intoOCA:16.0from
acsone:16.0-fix-compute_partner_bank_id-sbi

Conversation

@sbidoul
Copy link
Copy Markdown
Member

@sbidoul sbidoul commented Feb 11, 2025

The Odoo default computation for partner_bank_id on customer invoices sets the first bank account of the company.

The override in account_payment_partner resets it to false if there is no payment mode defined.

Since for customer invoices we usually don't define a payment mode (unless when using direct debit), this partner_bank_id field is therefore emptied.

This is problematic for instance when generating UBL invoices with the official Odoo module, because the bank account is mandatory to create a valid Peppol document.

Therefore I propose to keep the default behaviour if there is no payment mode on the invoice.

@sbidoul
Copy link
Copy Markdown
Member Author

sbidoul commented Feb 11, 2025

This is a more focused fix for #1408

@grindtildeath
Copy link
Copy Markdown
Contributor

@sbidoul I forward ported this change to v17.0 and fixed the test in #1423

@pedrobaeza
Copy link
Copy Markdown
Member

The idea behind the else part is for avoiding Odoo assigning a partner bank automatically, which does harm, as the payment/debit order auto-selection mechanism won't select the more suitable one, and you can see by the red CI that this is something intended.

@Tisho99
Copy link
Copy Markdown
Contributor

Tisho99 commented Feb 20, 2025

@grindtildeath

Yes, my module is based on the feature that an invoice does not have to have a bank account if it does not have a payment mode.

If this is going to be merged, my test and my module will need a little refactor to edit the default bank account if there is not a payment mode.

However, i think the best is waiting for the original v16 PR to be merged and resolve Pedro's comments

@grindtildeath
Copy link
Copy Markdown
Contributor

grindtildeath commented Feb 26, 2025

@pedrobaeza
This is actually breaking a core behaviour of Odoo. Although this might not suit your needs, it's breaking the swiss localization and we have to fix that.

IMO if someone wants to deactivate this assignation done by Odoo, which I can understand, I would suggest to add a setting (eg on the journal) so that the computation can rely on this setting to remove the automatically assigned value.

Please consider payment mode can be installed on an instance where it's not used by all the companies, in that case, it shouldn't break default behaviours as is the case with this compute.

@Tisho99 what do you think about adding such a setting?

@pedrobaeza
Copy link
Copy Markdown
Member

pedrobaeza commented Feb 27, 2025

Please specify which is the issue in the Swiss localization for determining if there are options to solve it.

@Tisho99
Copy link
Copy Markdown
Contributor

Tisho99 commented Feb 27, 2025

@grindtildeath

At first glance, I think that adding a configuration option is a good idea. If the default operation is left as it is now (setting the bank account to false if there is no payment method), it will not be necessary to refectorize other modules, just activate the option with Swiss accounting.

@sbidoul
Copy link
Copy Markdown
Member Author

sbidoul commented Feb 27, 2025

@pedrobaeza this is not only Swiss accounting. See the description of this issue. The default Odoo behaviour of selecting the company bank account on customer invoices is disabled, so various standard Odoo behaviours that depend on having the bank account populated do not work anymore. Peppol invoice generation is an example. Adding QR code to the invoices is another.

My question is why it is necessary to disable the default Odoo behaviour when there is no payment mode. I could not determine that by reading the code and the tests.

@pedrobaeza
Copy link
Copy Markdown
Member

The reasoning for emptying the bank account is to keep the "non deterministic" state until the payment/debit order is done. Check this use case (which is more usual than you think):

  • You issue an invoice with 60 days due date.
  • When the due is over, you make the debit order.
  • Meanwhile, the customer has changed its bank account.

Having the bank account fixed on invoice creation, provokes returns due to the invalid bank account number.

And a lot of users don't have decided yet on invoice issuing the payment mode, so they don't set it.

That's why we try to always keep it empty. In fact, we never mark the bank_account_required flag in the payment method in any of our installations.

I also remember a glitch that puts the bank account without this part on the invoice creation, but this may changed over the versions.

Removing this part, it will affect installations relying on that behavior.

Something we can do is to add a company flag bank_account_required for modeling both behaviors according it. Other option is to dynamically set the bank account if not set (this is already done for the invoice PDF if selected) on the PEPPOL file, but I suppose this is not under your control.

@github-actions
Copy link
Copy Markdown

github-actions bot commented Jul 6, 2025

There hasn't been any activity on this pull request in the past 4 months, so it has been marked as stale and it will be closed automatically if no further activity occurs in the next 30 days.
If you want this PR to never become stale, please ask a PSC member to apply the "no stale" label.

@github-actions github-actions bot added the stale PR/Issue without recent activity, it'll be soon closed automatically. label Jul 6, 2025
@sbidoul sbidoul removed the stale PR/Issue without recent activity, it'll be soon closed automatically. label Jul 6, 2025
@grindtildeath
Copy link
Copy Markdown
Contributor

@pedrobaeza @sbidoul How can we unblock this PR? It's a shame having to integrate this in all our 16.0+17.0 instances when account_payment_partner is installed

@pedrobaeza
Copy link
Copy Markdown
Member

Nobody has answered my comment at #1418 (comment), and anyway, this CI is red.

@remi-filament
Copy link
Copy Markdown
Contributor

Hi @pedrobaeza I think that the issue you describe in #1418 (comment) is valid for bills and out payments, but is not so relevant for customer invoices and in payment where what we want to add on account.move is our own bank account, not the one from the customer which can be calculated (this was already my proposal here : #1290 (comment))

@pedrobaeza
Copy link
Copy Markdown
Member

@remi-filament having only one field for the bank account, if you add your own bank account in there, the payment order will be issued incorrectly. Why is not OK to have that data dynamically populated in the invoice report? That's already the case. Do you know it?

@remi-filament
Copy link
Copy Markdown
Contributor

You mean here : https://github.com/odoo/odoo/blob/9ab9e254cb0658e38dc0b9c4fe54c317e184bb04/addons/account/views/report_invoice.xml#L207 ?

The point is that if you do not use any payment mode on customer invoices, the field is not filled anymore, so you need to fill it manually for each customer invoice you issue (even worse when using contracts where invoices are auto-generated and you do not expect to have to go to each to set your bank account)

@github-actions
Copy link
Copy Markdown

github-actions bot commented Dec 7, 2025

There hasn't been any activity on this pull request in the past 4 months, so it has been marked as stale and it will be closed automatically if no further activity occurs in the next 30 days.
If you want this PR to never become stale, please ask a PSC member to apply the "no stale" label.

@github-actions github-actions bot added the stale PR/Issue without recent activity, it'll be soon closed automatically. label Dec 7, 2025
@sbidoul sbidoul removed the stale PR/Issue without recent activity, it'll be soon closed automatically. label Dec 7, 2025
@cyrilmanuel
Copy link
Copy Markdown

hi @sbidoul is it possible to fix this pr or rebase this one ? this PR block others prs, perhaps we can go with this solutions no ?

…k_id

The Odoo default computation for partner_bank_id on customer invoices sets
the first bank account of the company.

The override in account_payment_partner resets it to false if there is no payment mode defined.

Since for customer invoices we usually don't define a payment mode (unless when using direct debit),
this partner_bank_id field is therefore emptied.

This is problematic for instance when generating UBL invoices with the official Odoo module,
because the bank account is mandatory to create a valid Peppol document.
@sbidoul sbidoul force-pushed the 16.0-fix-compute_partner_bank_id-sbi branch from 7435d4c to dbc8ff5 Compare February 10, 2026 13:07
@sbidoul
Copy link
Copy Markdown
Member Author

sbidoul commented Feb 10, 2026

@cyrilmanuel I rebased, but this PR is blocked by #1418 (comment). I still think this PR provides a better behaviour that respects how standard Odoo works, though.

@gurneyalex
Copy link
Copy Markdown
Member

@sbidoul

Pedro wrote:

Something we can do is to add a company flag bank_account_required for modeling both behaviors according it.

Is this something that would be acceptable? Could we contribute this to your pull request?

@sbidoul
Copy link
Copy Markdown
Member Author

sbidoul commented Feb 12, 2026

Is this something that would be acceptable? Could we contribute this to your pull request?

@gurneyalex Feel free to pick up this PR, of course.

felipemotter added a commit to Engenere/bank-payment that referenced this pull request Feb 16, 2026
…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.
@pedrobaeza
Copy link
Copy Markdown
Member

Merging #1555 that includes this, but through a configurable option.

@pedrobaeza pedrobaeza closed this Feb 16, 2026
felipemotter added a commit to Engenere/bank-payment that referenced this pull request Feb 17, 2026
…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.
felipemotter added a commit to Engenere/bank-payment that referenced this pull request Feb 17, 2026
…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.
felipemotter added a commit to Engenere/bank-payment that referenced this pull request Feb 17, 2026
…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.
felipemotter added a commit to Engenere/bank-payment that referenced this pull request Feb 17, 2026
…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.
felipemotter added a commit to Engenere/bank-payment that referenced this pull request Feb 17, 2026
…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.
felipemotter added a commit to Engenere/bank-payment that referenced this pull request Feb 17, 2026
…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.
felipemotter added a commit to Engenere/bank-payment that referenced this pull request Feb 18, 2026
…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.
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.

7 participants