Skip to content

Conversation

@sbidoul
Copy link
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.

…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
Copy link
Member Author

sbidoul commented Feb 11, 2025

This is a more focused fix for #1408

@grindtildeath
Copy link
Contributor

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

@pedrobaeza
Copy link
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
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
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
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
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
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
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

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
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
Member

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

@remi-filament
Copy link
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
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
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)

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.

5 participants