Skip to content

[FIX] 3pl_logistic_company: use product template in stock history cron#2450

Closed
fw-bot wants to merge 1 commit into
odoo:saas-19.3from
odoo-dev:saas-19.3-saas-19.3-3pl-logistic-company-server-action-fix-aycha-541230-fw
Closed

[FIX] 3pl_logistic_company: use product template in stock history cron#2450
fw-bot wants to merge 1 commit into
odoo:saas-19.3from
odoo-dev:saas-19.3-saas-19.3-3pl-logistic-company-server-action-fix-aycha-541230-fw

Conversation

@fw-bot

@fw-bot fw-bot commented Jun 30, 2026

Copy link
Copy Markdown

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

Forward-Port-Of: #2433

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
@robodoo

robodoo commented Jun 30, 2026

Copy link
Copy Markdown
Collaborator

Pull request status dashboard

@fw-bot

fw-bot commented Jun 30, 2026

Copy link
Copy Markdown
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>
@robodoo robodoo closed this Jul 1, 2026
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.

3 participants