Incorrect link between stock move on invoice line
We noticed something strange when cancelling a supplier shipment and using modules "purchase_invoice_line_standalone" and "account_invoice_stock".
To reproduce:
- Create a purchase (with one purchase line) and process
- Create a supplier shipment for this purchase
- Receive shipment -> purchase_invoice_line is created and linked to the incoming move
- Cancel shipment -> another purchase_invoice_line with negative quantity and no link with stock_move
- Handle exception on purchase to recreate shipment-> a new incoming_move is created
This new incoming_move will be linked to the purchase_invoice_line with negative quantity!
- Create a supplier shipment for this purchase
- Receive shipment -> another purchase_invoice_line is created and linked to the incoming move
So we will have 3 purchase_invoice_lines:
- one purchase_invoice_line linked to the cancelled incoming_move
- one purchase_invoice_line with negative quantity linked to the new incoming_move (should be the cancelled incoming_move or None)
- one purchase_invoice_line with positive quantity linked to the new incoming_move
Edited by Maxime Richez