[FIX] 3pl_logistic_company: use product template in stock history cron#2450
Closed
fw-bot wants to merge 1 commit into
Closed
Conversation
The scheduled action "Stock History - Create Daily Records" stores daily stock snapshots in `x_stock_history`. The `x_product_id` field is a many2one to `product.template`, but the cron was assigning the ID of the corresponding `product.product` record. This mismatch only works when both records happen to share the same ID. As soon as a product variant ID differs from its template ID, the scheduled action attempts to create a record with an invalid foreign key, causing a `ForeignKeyViolation` error and preventing the stock history from being generated. Use `sq.product_tmpl_id.id` instead of `sq.product_id.id` so the value matches the target model of the relation and the scheduled action consistently creates stock history records. Task-6333945 X-original-commit: 9bcac08
Collaborator
Author
|
This PR targets saas-19.3 and is part of the forward-port chain. Further PRs will be created up to master. More info at https://github.com/odoo/odoo/wiki/Mergebot#forward-port |
robodoo
pushed a commit
that referenced
this pull request
Jul 1, 2026
The scheduled action "Stock History - Create Daily Records" stores daily stock snapshots in `x_stock_history`. The `x_product_id` field is a many2one to `product.template`, but the cron was assigning the ID of the corresponding `product.product` record. This mismatch only works when both records happen to share the same ID. As soon as a product variant ID differs from its template ID, the scheduled action attempts to create a record with an invalid foreign key, causing a `ForeignKeyViolation` error and preventing the stock history from being generated. Use `sq.product_tmpl_id.id` instead of `sq.product_id.id` so the value matches the target model of the relation and the scheduled action consistently creates stock history records. Task-6333945 closes #2450 X-original-commit: 9bcac08 Signed-off-by: Vallaeys Valentin (vava) <vava@odoo.com>
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.

The scheduled action "Stock History - Create Daily Records" stores daily stock snapshots in
x_stock_history. Thex_product_idfield is a many2one toproduct.template, but the cron was assigning the ID of the correspondingproduct.productrecord.This mismatch only works when both records happen to share the same ID. As soon as a product variant ID differs from its template ID, the scheduled action attempts to create a record with an invalid foreign key, causing a
ForeignKeyViolationerror and preventing the stock history from being generated.Use
sq.product_tmpl_id.idinstead ofsq.product_id.idso the value matches the target model of the relation and the scheduled action consistently creates stock history records.Task-6333945
Forward-Port-Of: #2433