[FIX] 3pl_logistic_company: use product template in stock history cron#2433
Closed
aycha-odoo wants to merge 1 commit into
Closed
[FIX] 3pl_logistic_company: use product template in stock history cron#2433aycha-odoo wants to merge 1 commit into
aycha-odoo wants to merge 1 commit into
Conversation
Collaborator
ce126bb to
941f242
Compare
pgu-odoo
reviewed
Jun 30, 2026
vava-odoo
reviewed
Jun 30, 2026
941f242 to
5d1a5c8
Compare
5d1a5c8 to
6cba244
Compare
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
6cba244 to
0fe166b
Compare
vava-odoo
approved these changes
Jun 30, 2026
This was referenced Jun 30, 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.

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