odoo-valuation-repair
Broken inventory valuation — diagnose, repair, prevent
The invariant: for every storable product, Σ stock.valuation.layer.quantity
(the book) must equal physical stock in valued locations (internal +
company-owned transit, mirroring stock.location._should_be_valued()). The
displayed AVCO cost is just value_svl ÷ quantity_svl — when the book drifts,
the denominator hovers near zero and the "cost" becomes noise: negative,
absurdly large, and swinging on every move.
A negative cost is never the disease — it is the visible symptom of a broken
book. Products whose garbage cost happens to still be positive are the
silent majority (a repeating decimal like 505352.312312… betrays a tiny
denominator). Any monitor that only alerts on standard_price <= 0 misses
them; the drift check below does not.
Targets Odoo 17/18 (18 specifics flagged). SaaS-safe: everything here runs through XML-RPC + a server action — no shell or SQL console needed on the target.