Skip to Content
मेन्यू
This question has been flagged
2 Replies
533 Views

Looking for an SQL command to reset the quantity of all my inventoried parts to 0 before I do a physical.


Just not sure what field to set to 0.


Can someone help?

Avatar
Discard
Best Answer

Hi,

Resetting all inventoried parts to 0 quantity in Odoo using SQL is dangerous and not recommended unless you're working in a test/dev environment.


- In Odoo, stock levels are not stored directly in the product record.

- They are calculated based on stock moves and quant records.

-You should not manually zero inventory via SQL unless you're wiping clean a testing environment.


Try the following command.


UPDATE stock_quant

SET quantity = 0.0,

    reserved_quantity = 0.0

WHERE location_id IN (

    SELECT id FROM stock_location WHERE usage = 'internal'

);


-This does not create any traceable inventory adjustment it's a hard overwrite.

-It will not reflect properly in accounting.

-Stock valuation will be off unless you also handle stock_move, stock_valuation_layer, etc.


The safe way is the Physical Inventory Adjustment.


Hope it helps.

Avatar
Discard
Best Answer

For systems with transaction logging or audit trails, resetting stock directly in the database might bypass some important tracking. A safer method might be using a built-in function, if available.

Avatar
Discard