Skip to content

[FIX] deltatech_pos_stock: stock badge frozen on stale value in open sessions - #2834

Merged
dhongu merged 1 commit into
19.0from
19.0-fix-pos-stock-live-sync
Aug 19, 2026
Merged

[FIX] deltatech_pos_stock: stock badge frozen on stale value in open sessions#2834
dhongu merged 1 commit into
19.0from
19.0-fix-pos-stock-live-sync

Conversation

@dhongu

@dhongu dhongu commented Aug 19, 2026

Copy link
Copy Markdown
Owner

Problem

The stock badge on the POS product card (deltatech_pos_stock) could stay frozen at a stale
quantity for days in an already open session, even after real sales depleted the stock.

Root cause: qty_available on product.template is a non-stored computed field. A sale writes
on stock.quant, not on product.template, so the template's write_date never changes. The
POS incremental sync (pos.load.mixin) filters strictly on write_date > last_server_date, so
an already open session never gets the recalculated quantity re-sent - the badge stays at
whatever value was cached when the session's data was first loaded.

Reproduced and confirmed on a production instance (Damira): the badge showed a quantity that
matched real on-hand stock from several days earlier, not the current value, even though the
POS session had been opened fresh that same day.

Fix

stock.quant now pushes a live STOCK_SYNCHRONISATION bus notification - reusing the same
pos.bus.mixin channel core already uses for pos.config.notify_synchronisation (POS device
sync) - whenever a product's on-hand quantity changes, to every open POS session with
display_stock enabled. The frontend subscribes to this channel and merges the fresh
product.template data straight into the in-memory model, independent of the write_date-based
sync cycle.

Only quantity changes trigger a notification (not reserved_quantity), since the badge shows
on-hand stock (qty_available), not the forecasted/reserved quantity.

Test plan

  • Fresh install on a clean database (deltatech_pos_stock + demo data): existing badge test
    passes unchanged.
  • New test test_stock_badge_updates_live_without_reload: opens a POS session, confirms the
    initial badge value, then changes the product's stock quantity via RPC (simulating a sale
    from another till/channel) while the session stays open, and asserts the badge updates
    to the new value without any page reload.
  • Sanity-checked the new test actually detects the regression: temporarily disabled the
    notification call and confirmed the test fails (badge stays at the old value); restored
    the fix and both tests pass again.
  • pre-commit (ruff, eslint, pylint-odoo, prettier) passes clean.

Co-Authored-By: Claude Sonnet 5 noreply@anthropic.com

…sessions

qty_available is a non-stored computed field, so a sale (which writes on
stock.quant, not on product.template) never bumps the template's write_date.
The POS incremental sync filters on write_date, so an already open session
never receives the recalculated quantity again - the badge stays frozen at
whatever was cached when the session was first loaded, sometimes for days.

stock.quant now pushes a live STOCK_SYNCHRONISATION bus notification (same
pos.bus.mixin channel core already uses for notify_synchronisation) whenever
a product's on-hand quantity changes, to every open POS session with
display_stock enabled. The frontend subscribes and merges the fresh
product.template data straight into the in-memory model.

Reproduced and confirmed on a production instance: badge showed a quantity
that matched stock from several days earlier, not the current on-hand value.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@dhongu
dhongu merged commit 00435d0 into 19.0 Aug 19, 2026
5 checks passed
@dhongu
dhongu deleted the 19.0-fix-pos-stock-live-sync branch August 19, 2026 08:40
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.

1 participant