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 3 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 3 commits into
OCA:19.0from
Jenrax-git:19.0-IMP-subscription_oca-invoice-company-currency

Conversation

@stferraro

@stferraro stferraro commented May 20, 2026

Copy link
Copy Markdown

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.

  4. Add search view in module

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.

@stferraro

stferraro commented May 20, 2026

Copy link
Copy Markdown
Author

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

@stferraro

stferraro commented May 22, 2026

Copy link
Copy Markdown
Author

Hi @rickard-w please checks this functionality please !

@stferraro stferraro force-pushed the 19.0-IMP-subscription_oca-invoice-company-currency branch 2 times, most recently 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 :)

@jenrax-bot jenrax-bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Approved!

@Karla-Villegas Karla-Villegas left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

LGTM!

@OCA-git-bot

Copy link
Copy Markdown
Contributor

This PR has the approved label and has been created more than 5 days ago. It should therefore be ready to merge by a maintainer (or a PSC member if the concerned addon has no declared maintainer). 🤖

@stferraro

Copy link
Copy Markdown
Author

Hi @yvaucher please check this pr approve and merge!

@OCA-git-bot

Copy link
Copy Markdown
Contributor

@stferraro The merge process could not start, because command git merge tmp-pr-1433 failed with output:

Auto-merging subscription_oca/__manifest__.py
CONFLICT (content): Merge conflict in subscription_oca/__manifest__.py
Auto-merging subscription_oca/i18n/es.po
CONFLICT (content): Merge conflict in subscription_oca/i18n/es.po
Auto-merging subscription_oca/models/sale_subscription.py
Auto-merging subscription_oca/views/sale_subscription_views.xml
Automatic merge failed; fix conflicts and then commit the result.

1 similar comment
@OCA-git-bot

Copy link
Copy Markdown
Contributor

@stferraro The merge process could not start, because command git merge tmp-pr-1433 failed with output:

Auto-merging subscription_oca/__manifest__.py
CONFLICT (content): Merge conflict in subscription_oca/__manifest__.py
Auto-merging subscription_oca/i18n/es.po
CONFLICT (content): Merge conflict in subscription_oca/i18n/es.po
Auto-merging subscription_oca/models/sale_subscription.py
Auto-merging subscription_oca/views/sale_subscription_views.xml
Automatic merge failed; fix conflicts and then commit the result.

@stferraro stferraro force-pushed the 19.0-IMP-subscription_oca-invoice-company-currency branch from 49c06fe to e6bbb06 Compare June 28, 2026 11:36
…icelist and ensure company context in create_invoice
…icelist and ensure company context in create_invoice
…icelist and ensure company context in create_invoice
@stferraro stferraro force-pushed the 19.0-IMP-subscription_oca-invoice-company-currency branch from e6bbb06 to e09e56e Compare June 28, 2026 13:00
@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

@stferraro

Copy link
Copy Markdown
Author

/ocabot merge nobump

@OCA-git-bot

Copy link
Copy Markdown
Contributor

Sorry @stferraro you are not allowed to merge.

To do so you must either have push permissions on the repository, or be a declared maintainer of all modified addons.

If you wish to adopt an addon and become it's maintainer, open a pull request to add your GitHub login to the maintainers key of its manifest.

@stferraro

Copy link
Copy Markdown
Author

Hi, @alvaro-domatix this PR has been approved for a while but I don't have merge permissions on this repo (I'm not yet a declared maintainer of subscription_oca). Could you please run:

/ocabot merge patch

Thanks a lot for your time!

@OCA-git-bot

Copy link
Copy Markdown
Contributor

Sorry @stferraro you are not allowed to merge.

To do so you must either have push permissions on the repository, or be a declared maintainer of all modified addons.

If you wish to adopt an addon and become it's maintainer, open a pull request to add your GitHub login to the maintainers key of its manifest.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants