Skip to content

[IMP] subscription_oca:set invoice currency to subscription pricelist and ensure company context in create_invoice#1433

Open
stferraro wants to merge 2 commits into
OCA:19.0from
Jenrax-git:19.0-IMP-subscription_oca-invoice-company-currency
Open

[IMP] subscription_oca:set invoice currency to subscription pricelist and ensure company context in create_invoice#1433
stferraro wants to merge 2 commits into
OCA:19.0from
Jenrax-git:19.0-IMP-subscription_oca-invoice-company-currency

Conversation

@stferraro
Copy link
Copy Markdown

@stferraro stferraro commented May 20, 2026

In multi-company and multi-currency setups, invoices generated from subscriptions may not consistently enforce:

The subscription pricelist currency on the created invoice.

The subscription company context during invoice creation.
This can lead to inconsistent invoice values or cross-company context issues in downstream implementations.

Describe the solution you'd like
Implement the following in subscription_oca:

  1. Ensure invoice values explicitly set currency_id from subscription.pricelist_id.currency_id when preparing account.move values.

  2. Ensure create_invoice runs under subscription.company_id context (with_company) before creating the invoice.

Also add unit tests to validate:

  1. Invoice currency matches subscription pricelist currency.

  2. Invoice company matches subscription company in multi-company scenarios.

  3. Multi-Company Security: Ensure proper record rules are defined so users in multi-company environments don't face access errors or leakages.

Describe alternatives you've considered

  1. Keep this behavior in downstream custom modules only.

  2. Override invoice creation in each deployment that needs strict multi-company/multi-currency behavior.

These alternatives duplicate logic across projects and increase maintenance cost compared to handling it upstream.

Additional context
I can submit a PR for 19.0 including implementation and tests.

…icelist and ensure company context in create_invoice
@stferraro
Copy link
Copy Markdown
Author

stferraro commented May 20, 2026

Hi, @sbidoul @CristianoMafraJunior @thib-d @yvaucher check this functionality added to subscription oca and approve please

@stferraro
Copy link
Copy Markdown
Author

stferraro commented May 22, 2026

Hi @rickard-w please checks this functionality please !

@stferraro stferraro force-pushed the 19.0-IMP-subscription_oca-invoice-company-currency branch from c3b0d03 to 9d60448 Compare May 26, 2026 21:00
…icelist and ensure company context in create_invoice
@stferraro stferraro force-pushed the 19.0-IMP-subscription_oca-invoice-company-currency branch from 9d60448 to bc31d17 Compare May 26, 2026 21:17
@stferraro
Copy link
Copy Markdown
Author

@OCA-git-bot mainteiners contract approve

@stferraro
Copy link
Copy Markdown
Author

/ocabot merge --no-bump

@OCA-git-bot
Copy link
Copy Markdown
Contributor

Hi @stferraro. Your command failed:

Required option bumpversion_mode for command merge. Possible values : major, minor, patch, nobump.

Ocabot commands

  • ocabot merge major|minor|patch|nobump
  • ocabot rebase
  • ocabot migration {MODULE_NAME}

More information

@rickard-w
Copy link
Copy Markdown

Hi @stferraro
I have tried my best to force any issues with the subscription invoice. But as far as I can tell, everything seems to work as it should. Good job.

@stferraro
Copy link
Copy Markdown
Author

Hi @rickard-w , thanks for your comment please approve this PR

@stferraro
Copy link
Copy Markdown
Author

Hi @pedrobaeza, when you have a chance, could you please review this PR? Otherwise, could you tag someone who can review and approve it?

@rickard-w
Copy link
Copy Markdown

Hi @rickard-w , thanks for your comment please approve this PR

I don't have the permission to approve. And honstly, I don't know if I have the skills either :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants