important MRP bug: wrong virtual stock after cancelling production/purchase generated by MTS procurement
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
Odoo Addons (MOVED TO GITHUB) |
Fix Released
|
Undecided
|
Fabien (Open ERP) |
Bug Description
https:/
Hi,
this bug is reproducible on trunk with a fresh manufacturing database.
Configure a product with:
- procurement method: MTS
- procurement: buy or produce
Make sure you define a minimum order point rule for that product and the current warehouse.
Now make a customer sale order so that you don't have enough product in stock and you should produce or buy the product.
validate the sale order.
Look the product virtual stock level: it's lower than before because of the order.
Now run the scheduler.
The scheduler create a purchase (or production order) to for the product, as a result, the virtual stock level
just increased just like it was before the customer order.
The trouble is that if you open the related purchase (or production) order and cancel it, then
the virtual stock level remains as high as before.
This is a bug because you just cancelled the planned purchase or production!
Here is what happened:
when you validated the sale order, a MTS procurement has been generated to put products again in Stock.
But, at the beginning of the procurement workflow, the procurement had no move, so a confirmed move
form procurement to stock has been created. It is because of that move creation after you run the scheduler that the
virtual stock level has been increased. Indeed, the MRP egine used that move to artifially increase the virtual
stock level in order to reflect our plan to buy/produce the product.
The move creation happens in addons/
if not procurement.
The problem is that this move will stay here foreever; cancelling the related purchase/production order will NOT
cancel that confirmed move. As a consequence, virtual stock level are wrong; they are too optimistic.
What should be done instead?
the confirmed procurement -> Stock move should stop increasing the virtual stock level.
A case when it happens is when you actually validade the related purchase order instead of cancelling it. In this case,
a new move suppliers -> Stock is created and the previous procurement -> Stock move is voided. The way it's voided
is it is transformed into a Stock -> Stock move so it has no effect. I'm not sure if that is better than cancelling the move
but it's the way it's done currently.
So, at least for the MTS+buy case, I'm proposing a patch (attached) doing something similar: I change the purchase workflow so thatwhen the purchase is cancelled right after it's creation, now we run a full server action. And that existing action (which is doing a bit more but without any risk) is now extended to change the procurement -> Stock move into a Stock -> Stock move so the virtual stock won't take it into account anymore.
I think my patch is correct but it only fixes the MTS + buy case.
A similar patch should be done to fix the MTS + produce case, probably using the production workflow but I had no time to elaborate it sorry.
Hope this helps,
Raphaël Valyi
Changed in openobject-addons: | |
status: | Fix Released → Confirmed |
I think the MTS+produce case is correct. Because if you cancel a production, it cancels moves, which cancels the procurement too. The purchase is different because you don't have the moves before having confirmed the po.