Continuing the discussion from Minimal e-shop for Tryton:
Some sale work-flow like online sale requires to have the payment before validating the sale (and so before having an invoice). Indeed the payment is the validation of the quotation.
We add an origin on the payment which can point to a sale.
The sale can not be validated if there are payments linked to it and they are not succeeded for the amount of the sale.
When an invoice for the sale is posted, we link the existing succeeded sale payments to the payable line. To work properly, the invoice should not have a payment term (neither the sale) and the invoice method must be “On Order Processed” to ensure that only one payable line will be created.