How to create payment term from xml

Hi community,

im creating a custom invoice module with payment term from xml,

i have this:

<data>
    <record model="account.invoice.payment_term" id="payment_cash">
        <field name="name">Cash Payment</field>
        <field name="description">Cash Payment</field>
    </record>
</data>

<data>
    <record model="account.invoice.payment_term.line" id="payment_line_cash">
        <field name="payment" ref="payment_cash"/>
        <field name="type">remainder</field> 
    </record>
</data>

but im receiving this error:

trytond.exceptions.UserError: Last line of payment term “Cash Payment” must be of type remainder.

What am I missing?

thanks

The validation constraint makes that payment term can not be created in two steps (main record then lines).
Maybe check_remainder should not raise an error when there is no lines as we raise an error also on compute.