DEV Community

Fabian Anguiano
Fabian Anguiano

Posted on • Edited on

How to fix "It is not possible to unreserve more products of ... than you have in stock." in Odoo

Have you been hit with the "It is not possible to unreserve more products of ... than you have in stock." bug? Run this script to solve your issues.

  1. The issue has way to many variables to properly track down the issue at scale. If you search forums, you will find multiple DB's and instance types having the issue.

  2. No matter how your move/record got bugged, the bottom line is in Odoo's system there is simply not enough product to unreserve or cancel the move.

  3. This fix runs a brute force, solution and should only be done as a last resort. Back up your DB and run on a test instance before.

The script will overwrite both the reserved and real quantity, so that the bugged moved can close.

Example*

Say you have a record for product x for a total of 100, that you can't cancel. The script would overwrite the product and location qty's to 100 (regardless of what it should be), so that we can cancel the move.

Plug in your login info and product info. Note: Login should probably be env variables, as we are running locally I didn't bother sitting this up.

Run the script and find stock.quant record to overwrite, after you overwrite it, go back to the move and you will no be able to cancel it.

 rsv_qty = models.execute_kw(db, uid, password, 'stock.quant', 'write',
                            [room_id, {
                                'reserved_quantity': overwrite_number, 
                            }])
    print("Reserved Overwrite Successful")


    rsv_qty = models.execute_kw(db, uid, password, 'stock.quant', 'write',
                            [room_id, {
                                'quantity': overwrite_number, 
                            }])
    print("Real Overwrite Successful")
Enter fullscreen mode Exit fullscreen mode

https://github.com/thetrebelcc/Odoo-Unable-to-Unreserve-Fix-Script

Image description

Top comments (0)