bank-payment icon indicating copy to clipboard operation
bank-payment copied to clipboard

[FIX] account_payment_partner: keep the default value for partner_bank_id

Open sbidoul opened this issue 1 year ago • 16 comments

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 avatar Feb 11 '25 16:02 sbidoul

This is a more focused fix for #1408

sbidoul avatar Feb 11 '25 16:02 sbidoul

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

grindtildeath avatar Feb 19 '25 18:02 grindtildeath

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.

pedrobaeza avatar Feb 20 '25 08:02 pedrobaeza

@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

Tisho99 avatar Feb 20 '25 09:02 Tisho99

@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?

grindtildeath avatar Feb 26 '25 23:02 grindtildeath

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

pedrobaeza avatar Feb 27 '25 07:02 pedrobaeza

@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.

Tisho99 avatar Feb 27 '25 08:02 Tisho99

@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.

sbidoul avatar Feb 27 '25 09:02 sbidoul

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.

pedrobaeza avatar Mar 01 '25 10:03 pedrobaeza

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[bot] avatar Jul 06 '25 12:07 github-actions[bot]

@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

grindtildeath avatar Jul 11 '25 18:07 grindtildeath

Nobody has answered my comment at https://github.com/OCA/bank-payment/pull/1418#issuecomment-2692140380, and anyway, this CI is red.

pedrobaeza avatar Jul 11 '25 18:07 pedrobaeza

Hi @pedrobaeza I think that the issue you describe in https://github.com/OCA/bank-payment/pull/1418#issuecomment-2692140380 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 : https://github.com/OCA/bank-payment/issues/1290#issuecomment-2561110404)

remi-filament avatar Aug 04 '25 16:08 remi-filament

@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?

pedrobaeza avatar Aug 04 '25 16:08 pedrobaeza

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)

remi-filament avatar Aug 04 '25 16:08 remi-filament

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[bot] avatar Dec 07 '25 12:12 github-actions[bot]