Skip to content

[18.0][FIX] account_operating_unit: filter payment register journals by OU (#843)#844

Open
IJOL wants to merge 2 commits intoOCA:18.0from
BITVAX:18.0-fix-payment-register-ou
Open

[18.0][FIX] account_operating_unit: filter payment register journals by OU (#843)#844
IJOL wants to merge 2 commits intoOCA:18.0from
BITVAX:18.0-fix-payment-register-ou

Conversation

@IJOL
Copy link
Copy Markdown

@IJOL IJOL commented Apr 9, 2026

Fixes #843 — payment register wizard shows journals from wrong OU

Problem (see #843)

When registering a payment from the invoice form, the payment wizard shows journals from all operating units instead of filtering by the invoice's OU. Users with restricted OU access get AccessError when creating payments.

Steps to reproduce

  1. Configure two operating units (OU_A, OU_B) with separate bank/cash journals
  2. Create a user with access to only OU_B
  3. Create and post a vendor bill assigned to OU_B
  4. Click Register Payment — journals from OU_A appear in dropdown
  5. Click Create Payment → AccessError on account.journal

Fix

Override _get_batch_available_journals in account.payment.register to filter journals by the invoice's operating unit when all invoices in the batch share the same OU.

Test

Added test_payment_register_journals_filtered_by_ou — creates a vendor bill for a specific OU, opens payment wizard, asserts only matching journals are available, and confirms payment creation succeeds.

When registering a payment from the invoice form, the payment wizard
shows journals from all operating units instead of filtering by the
invoice's operating unit. This causes AccessError when users with
restricted OU access try to create payments.

Override _get_batch_available_journals in account.payment.register
to filter journals by the invoice's operating unit when all invoices
in the batch belong to the same OU.
@IJOL IJOL force-pushed the 18.0-fix-payment-register-ou branch from 554dbbf to 8c13f76 Compare April 9, 2026 07:07
Copy link
Copy Markdown
Contributor

@AaronHForgeFlow AaronHForgeFlow left a comment

Choose a reason for hiding this comment

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

Code review LGTM

.create(inv_vals)
)
invoice.action_post()

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

sorry for the nitpicking, can you remove all the empty lines inside the method?

@OCA-git-bot OCA-git-bot added mod:account_operating_unit Module account_operating_unit series:18.0 labels Apr 13, 2026
The 8c13f76 fix added _get_batch_available_journals override but
shipped without a regression test. This adds one: a B2B-only user
pays a B2B invoice via the Register Payment wizard, and the
available_journal_ids must NOT include OU1 journals.
@IJOL IJOL force-pushed the 18.0-fix-payment-register-ou branch from f07358c to 35f9779 Compare April 13, 2026 16:28
IJOL added a commit to BITVAX/operating-unit that referenced this pull request Apr 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

mod:account_operating_unit Module account_operating_unit series:18.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[18.0][BUG] account_operating_unit: payment register wizard shows journals from wrong OU

3 participants