Manual payment term on invoice

Rational

The payment terms are great and quite flexible to automate the computation of the due amount and date. But sometimes we could want to use a particular set of dates and amount but it is so custom that you do not want to create a payment term for it. For example, the customer has negotiated a particular term for one invoice; or the supplier has terms that are not as straight as the Tryton’s payment term; or one time supplier has very special terms for which we do not want to create payment term.
So I think it will be good to let the user fill the term result manually. It is the logical continuation of the optional payment term change.

Proposal

We add a payment_date field which hide the payment_term if filled (and vice versa). The date must be greater or equal to the invoice date. When filled, it is used as maturity_date for the term line.
We add on a tab a One2Many of payment_term_lines which is visible only if both payment_term and payment_date are empty (and hide the other if filled). The line stores a date and an amount (with the default value equals to the invoice amount minus amount of other lines). The sum of the lines’ amount must be equal to the invoice amount. If filled, those dates and amount are used as term lines.
All the fields are read-only once the invoice is validated.
When the invoice is credited, those fields are emptied.

Implementation