This question has been flagged
8 Replies
48089 Views

How to delete the stock moves when they are in "done" state?

Avatar
Discard
Best Answer

Short answer - you cannot - for your own good.

This is a fundamental of double entry bookkeeping, every movement has a credit and a debit. It makes it easier to track where your money is going.

It is poor accounting practices to just re-write entries in the ledger. If you made a mistake, make a correcting entry that cancels out the old stock move. Like if you shipped it to a partner in the computer by mistake, create a return with a note that this was just a computer error.

If your database is getting too big, I would see about exporting the information somehow.

Avatar
Discard

Sometimes it would be better. For example, in multi-company accidentally locking a product into the wrong company. Odoo's UX makes this error occur very easily.

Best Answer

Hi,

This module will help you reset stock inventory within a second,

https://www.odoo.com/apps/modules/11.0/td_reset_stock_moves/

More information contact to : tidyway.in@gmail.com

Regards,

Rohan

Avatar
Discard
Best Answer

OpenERP prevents you from deleting stock moves that are not in the DRAFT state. If a stock move is DONE by mistake (should not have been completed), then you need to create another stock move that is the opposite of the mistake move.

Avatar
Discard

I find it absurd that there is no safe way for the administrator to remove these records. In adjusting the workflow and testing it there are now dozens of test moves I want gone. I guess I have no choice but use SQL to force them all back to draft state so I can safely delete them. Ugly. Why can't the admin have tools for this that normal users will never access?

100% agree. There are bugs that generate Stock moves that I need to delete but can't. For example, I have a Product set as Make to Stock that is in stock but a Delivery Order has somehow generated a Manufacturing Order and confirmed the stock moves. I need to delete that. I don't need to be protected from this.

SQL is the method you can use if you don't want to be protected from the business logic. Make sure you understand exactly what you are doing.

Best Answer
update stock_move set state = 'draft' where id = ?;

Then you can delete them from within OpenERP safely. Or if safety is not a concern...

delete from stock_move where id = ?;

I don't recommend the latter but I've had to do it when a CSV upload test generated several hundred test records and I needed them gone for the next iteration of testing.

Avatar
Discard
Best Answer

In Odoo 11 onwards, When Delivery or shipment is in the done state, There is Unlock button.

When you click on this, Order become unlock and you will get an option to edit a Done Qty in Move lines.

If you want to just cancel the order, you can simply provide done qty as 0 and again lock it.

Effect of this is, you onhand qty for a product will decrease for shipment or increase for delivery as stock move receive 0 qty. It is the most safest way as it takes care of all stock related and inventory related odoo flow.

Avatar
Discard