Skip to content

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

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

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

Conversation

@aycha-odoo

Copy link
Copy Markdown
Contributor

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

@robodoo

robodoo commented Jun 30, 2026

Copy link
Copy Markdown
Collaborator

Pull request status dashboard

@C3POdoo C3POdoo requested a review from a team June 30, 2026 06:15
@aycha-odoo aycha-odoo force-pushed the saas-19.3-3pl-logistic-company-server-action-fix-aycha branch from ce126bb to 941f242 Compare June 30, 2026 06:20
Comment thread 3pl_logistic_company/__manifest__.py
Comment thread 3pl_logistic_company/__manifest__.py
Comment thread 3pl_logistic_company/data/ir_cron.xml
@aycha-odoo aycha-odoo changed the base branch from saas-19.3 to saas-18.4 June 30, 2026 09:43
@aycha-odoo aycha-odoo changed the base branch from saas-18.4 to saas-19.3 June 30, 2026 09:45
@aycha-odoo aycha-odoo force-pushed the saas-19.3-3pl-logistic-company-server-action-fix-aycha branch from 941f242 to 5d1a5c8 Compare June 30, 2026 09:50
@aycha-odoo aycha-odoo changed the base branch from saas-19.3 to saas-18.4 June 30, 2026 09:50
@aycha-odoo aycha-odoo changed the base branch from saas-18.4 to saas-19.3 June 30, 2026 09:59
@aycha-odoo aycha-odoo changed the base branch from saas-19.3 to saas-18.4 June 30, 2026 10:17
@aycha-odoo aycha-odoo force-pushed the saas-19.3-3pl-logistic-company-server-action-fix-aycha branch from 5d1a5c8 to 6cba244 Compare June 30, 2026 10:19
@aycha-odoo aycha-odoo changed the base branch from saas-18.4 to 19.0 June 30, 2026 13:21
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
@aycha-odoo aycha-odoo force-pushed the saas-19.3-3pl-logistic-company-server-action-fix-aycha branch from 6cba244 to 0fe166b Compare June 30, 2026 13:22

@vava-odoo vava-odoo left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants