Name: [FIX] stock: soft correct unsynch between quant and stock.move.line

State: Killed

PR State: merged

PR Author: Roy Le

PR Author Email:

PR: #1231

Committer: Roy Le

Committer Email: roy.le@viindoo.com

Commit: db8cad3505669e3e7f8ab97ced80a59085a582aa

Description:

                                            [FIX] stock: soft correct unsynch between quant and stock.move.line

It happens due to many reasons that the `stock.quant` object and
`stock.move.line` loose their synchronisation and it could have a
difference between the sum of `stock.move.line` and the quantity/reserved
quantity on the `stock.quant`

It's important to keep tracking why the desycnh happens and to fix all
the root causes of it.

However, it's hard for the user to clean the data himself or even worst
to lock him when it happens (as before 18.0).

For quantity: It's not a big deal to have a huge difference between the
quantity and all the long time history. As in real life, the inventory
adjustement can help to clean the data.

For reserved quantity: It's a bigger problem since the user can't edit
it. A first step would be to never write it to a negative value (since
it should never happen). That way when the user empty the stock, it will
also probably clean the reserved quantity. But in case where there is
more reservation than on `stock.move.line`. We should also clean it to
be able to reserve them. Currently, we will try in the scheduler for
that part

A last step, could be to create a constraint during test that ensure
the synch is never broken and it could raise directly if the developer
made a mistake

closes odoo/odoo#188201

Signed-off-by: William Henrotin (whe) <whe@odoo.com>
                                            

Branch: 17.0

Instance ID: 0

Age:

Up-time: Not finished