Supplier reception error, how to fix?

We have 2 purchases for the same supplier and same product. A user made the reception on the wrong order by mistake. This user identified his error after finalizing the first reception, he then received the correct purchase order directly.
We now have 2 validated receptions: purchase 1 and purchase 2. Purchase number 2 should arrive in 2 months in our stocks.
We therefore currently have an incorrect stock and a pending invoice line that is also incorrect.
In the reception schedule, we no longer have anything pending, which is also incorrect.

The simple solution is to make a supplier return to correct the stock, but this solution does not put a supplier reception on hold and will not correct the invoice line.

I am thinking of making an intervention in the database to delete the incorrect reception, but this requires a lot of manual correction: deletion of lines in different tables, modification of status, etc.

Do you have any idea of ​​a procedure to correct this type of problem?

Since Allow cancelling done move (#11663) · Issues · Tryton / Tryton · GitLab we allow to cancel move in the state done, I’m wondering if we should not allow to cancel shipment in the state done as long as we can cancel all the moves.
Of course the linked purchase (or sale) may have already create the invoice line but in this case we can expect that the user will also manually delete those lines (if he could).

I would try to allow the transition from done to cancelled in the shipment and see what happens.

So we have added the transition:

class ShipmentIn(metaclass=PoolMeta):
    __name__ = 'stock.shipment.in'

    @classmethod
    def __setup__(cls):
        super().__setup__()
        cls._transitions.add(('done', 'cancelled'))

and then we cancelled the supplier shipment with the trytond-console:

from trytond.pool import Pool
pool = Pool()
ShipmentIn = pool.get('stock.shipment.in')
shipmentin = ShipmentIn(id_record) # get id_record from the log
shipmentin.state
ShipmentIn.cancel([shipmentin])
transaction.commit()
shipmentin.state

Then we could handle shipment exception from purchase :slight_smile:
Indeed, we should also care about invoice.
Thanks !

I think you can propose a merge request.

1 Like