Do not recall all advance payment
The sale_advance_payment
module recall all the advance payment on the first invoice created. But this can lead to a credit note if the invoice method is based on shipment and that we shipped less than the amount of the advance.
I think we should manage on the sale.advance_payment.condition
the amount having been recalled and so link the recall invoice line to it instead of the advance invoice line. (This will require a migration to change the origin of previous lines).
The recall method should limit the amount recalled up to the invoice amount (taking care of the taxes amount also).
Also when the sale is marked as invoiced, we should check that all amount of advance payment has been recalled otherwise it must create a credit note to reimburse it.