Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[15.0][FIX] account_payment_order: Filter bank on company #1237

Merged

Conversation

hhgabelgaard
Copy link

In multi company setup, we need to filter res.partner.bank for current (payment order) company, or shared partner bank account (No company set)

@pedrobaeza pedrobaeza added this to the 15.0 milestone Mar 7, 2024
@pedrobaeza pedrobaeza changed the title [FIX] account_payment_order: Filter bank on company [15.0[FIX] account_payment_order: Filter bank on company Mar 7, 2024
@pedrobaeza pedrobaeza changed the title [15.0[FIX] account_payment_order: Filter bank on company [15.0][FIX] account_payment_order: Filter bank on company Mar 7, 2024
Copy link
Member

@pedrobaeza pedrobaeza left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I understand that the problem is that you have selected more than one company at the same time when preparing the payment order. I think the cleanest patch should be to do self.partner_id.with_context(allowed_company_ids=self.company_id).bank_ids instead. What do you think?

account_payment_order/models/account_move_line.py Outdated Show resolved Hide resolved
@hhgabelgaard
Copy link
Author

hhgabelgaard commented Mar 12, 2024

I understand that the problem is that you have selected more than one company at the same time when preparing the payment order.

No, Only one company selected. But this shouldn't depend on access / ir.rule

I think the cleanest patch should be to do
self.partner_id.with_context(allowed_company_ids=self.company_id).bank_ids instead. What do you think?

Didn't know that trick - And it seems to depend on access / ir.rules. i.e won't work in a background job run by the system user
My inspiration was how core does it, e.g. https://github.com/odoo/odoo/blob/15.0/addons/account/models/account_move.py#L532

@hhgabelgaard hhgabelgaard force-pushed the 15.0-issue47882-partner-bank-access-hhg branch from a3f7726 to 9df2913 Compare June 17, 2024 07:57
@hhgabelgaard
Copy link
Author

@pedrobaeza Your suggestions has been applied.
Thanks for the input/review

@pedrobaeza
Copy link
Member

You have modified slightly my suggestions, why? Mine is more compact and descriptive.

@hhgabelgaard hhgabelgaard force-pushed the 15.0-issue47882-partner-bank-access-hhg branch from 9df2913 to 62c4bc9 Compare June 17, 2024 08:41
@hhgabelgaard
Copy link
Author

Because I assumed this [:1].id would fail with IndexError: tuple index out of range if the filtered list is empty....
As [0] does...
But It seems to work beautifully, and yes, it is more compact and descriptive.

Copy link

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 Oct 20, 2024
@github-actions github-actions bot closed this Nov 24, 2024
@pedrobaeza pedrobaeza reopened this Nov 25, 2024
@pedrobaeza
Copy link
Member

/ocabot merge patch

Please fw-port it to upper versions.

@OCA-git-bot
Copy link
Contributor

What a great day to merge this nice PR. Let's do it!
Prepared branch 15.0-ocabot-merge-pr-1237-by-pedrobaeza-bump-patch, awaiting test results.

@OCA-git-bot OCA-git-bot merged commit 5ed0536 into OCA:15.0 Nov 25, 2024
10 of 13 checks passed
@OCA-git-bot
Copy link
Contributor

Congratulations, your PR was merged at 87a2308. Thanks a lot for contributing to OCA. ❤️

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
merged 🎉 stale PR/Issue without recent activity, it'll be soon closed automatically.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants