Skip to Content
Menu
This question has been flagged
7 Replies
9077 Views

I am trying to validate a return stock picking, but I keep getting this error "It is not possible to unreserve more products of ... than you have in stock". I check the forecasted inventory and the quantity on hand, and everything should work well. I hope someone knows how to fix this issue.

I am using odoo 15 community edition.

Edit: I found several posts addressing this issue, but none of the solutions worked for me.

Avatar
Discard
Best Answer

The way i did is in the fallowing video  and it worked .. 

you will endup having a component not consumed, but you can at least mark as done the MO
https://screencast-o-matic.com/watch/c3jZlDVTONK


Avatar
Discard
Author

This way is far better than directly editing the database. Thank you for the explanation.

Marvelous solution without coding and very robust. Thank you!

Best Answer

Hi,

Enable debug mode and navigate to server action menu under settings and see if there is a server action named:  Correct inconsistencies for reservation

If found, click on Run button, which will solve the issue, if server action is not found, pull the latest source code of corresponding odoo version and upgrade the stock module.


More info:  https://github.com/odoo/odoo/commit/e0e63be484b0ebddc7d498a4a13b2ba7a7f1a1f4#diff-c0d27a4adc8bbd305125f4e2729e30fe444fdd4e5ca0f96f2dd7f1fab19fe80eR17


Thanks

Avatar
Discard
Best Answer

Hello

I was able to resolve this issue using SQL queries. I had forcefully unreserve the quantities from database using queries. 
I added queries in server action and execute this server action on transfer

# Update the stock_move_line table to reset reserved quantities:
env.cr.execute(
"""UPDATE stock_move_line SET reserved_uom_qty = 0,reserved_qty = 0 WHERE reserved_qty > 0 AND state IN ('assigned', 'partially_available');"""
)
# Update the stock_quant table to reset reserved quantities
env.cr.execute(
"""UPDATE stock_quant SET reserved_quantity = 0 WHERE reserved_quantity > 0;"""
)
# Reset the state of stock_move records if needed:
env.cr.execute(
"""UPDATE stock_move SET state = 'confirmed' WHERE state IN ('partially_available', 'assigned');"""
)

Avatar
Discard
Best Answer

hello, can you write your sql query for now?

Avatar
Discard
Best Answer

I had this issue recently and the way I solved it was going into the product's form view, opening the "On Hand" smart button and editing the view with developer mode.

add the column

field name="reserved_quantity" readonly="0"


And edit the reserved quantity to be equal to the desired quantity. In my case it was the amount reserved on a manufacturing order, but it seems in this case it would be the "On Hand" quantity (my error was that I couldn't unreserve more than what I had already reserved).

After this make sure you save and you can delete the column from the view again (or at least remove the readonly="0" to avoid unintentional changes)

Avatar
Discard

Using the below query, I could determine which products were affected (matching the product featured in the situation in my database). To resolve the issue, I set the Reserved qty to the total_product_qty returned from this query.

WITH
quant_data AS (
SELECT
sq.product_id,
sq.location_id,
SUM(sq.reserved_quantity) AS total_reserved_quantity
FROM
stock_quant sq
GROUP BY
sq.product_id, sq.location_id
),
move_line_data AS (
SELECT
sml.product_id,
sml.location_id,
SUM(sml.product_qty) AS total_product_qty
FROM
stock_move_line sml
WHERE
sml.product_qty != 0
GROUP BY
sml.product_id, sml.location_id
)
SELECT
qd.product_id,
qd.location_id,
qd.total_reserved_quantity,
mld.total_product_qty
FROM
quant_data qd
JOIN
move_line_data mld
ON
qd.product_id = mld.product_id
AND
qd.location_id = mld.location_id
WHERE
qd.total_reserved_quantity != mld.total_product_qty;

Best Answer

we also had this problem and were able to identify it as a bug. By the way, it was the first time that Odoo admitted that there really is a bug! I can't explain exactly what the solution was in the end, but it was related to a (well known) rounding error (this can be found in numerous posts here)

Avatar
Discard

Do you know the github issue number this is listed on?
If possible, can you post the link?

Author Best Answer

It took me a while but I was able to solve this issue with an unrecommended method.

I had to forcefully unreserve the quantities directly from the database. I looked for the order id then identified the reservation ids too. All I had to do is to delete those. In the stock picking I was successfully able to cancel the order then delete it without any errors.

I don't remember the SQL queries I executed. I will write them here once I do.

Avatar
Discard
Related Posts Replies Views Activity
2
Jun 22
3883
0
Apr 24
1669
1
Jun 23
5288
1
May 22
3051
0
Mar 20
3138