[18.0] [FIX] subscription_oca: prevent CRM tag context pollution on subscription create#1420
Open
rrebollo wants to merge 1 commit into
Open
Conversation
…tion create When confirming a sale.order from a CRM opportunity, sale_crm injects default_tag_ids (containing crm.tag IDs) into the context. Without this fix, those IDs are applied by default_get() to sale.subscription.tag_ids, causing a FK constraint violation on sale_subscription_sale_subscription_tag_rel. Fix: use clean_context() from odoo.tools to strip all default_* keys from context before calling sale.subscription.create(), following the idiomatic Odoo core pattern used in res_bank, account_move, hr_expense_sheet, etc. Adds a regression test that reproduces the production scenario end-to-end.
tarteo
approved these changes
May 6, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When confirming a sale.order from a CRM opportunity, sale_crm injects default_tag_ids (containing crm.tag IDs) into the context. Without this fix, those IDs are applied by default_get() to sale.subscription.tag_ids, causing a FK constraint violation on sale_subscription_sale_subscription_tag_rel.
Fix: use clean_context() from odoo.tools to strip all default_* keys from context before calling sale.subscription.create(), following the idiomatic Odoo core pattern used in res_bank, account_move, hr_expense_sheet, etc.
Adds a regression test that reproduces the production scenario end-to-end.
@BinhexTeam T18387