This question has been flagged
4 Replies
4732 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

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

hello, can you write your sql query for now?