Being new to Tryton programming I’ve the following thoughts on Wolf’s issue, and I’d be happy for comments on my approach:
The module sale-invoice-grouping generates items in account.invoice.line without setting the field sequence. So the sort order is set by python itself, it looks as it’s often more or less driven by random.
Because I do not (yet) understand how the module sale-invoice-grouping works and how it can be adjusted to set the sort order, I would suggest to set the field account.invoice.line.sequence for all lines belonging to the invoice before printing.
With the help of the field account.invoice.line.origin it’s possible to get the record in sale.line and with the field sale.line.sale it’s possible to get the record in sale.sale. The fields sale.sale.sale_date and sale.sale.shipping_date are containing the necessary informations for the sorting order.
By collecting all these dates for all invoice lines it should be possible to set sorting order as requested.
Is it true this could be implemented as a new action for the module account-invoice? And if so, where can I find more info on how to add a new action?
Without the knowledge of adding a new action I’d implement it as a proteus script.
Thanks in advance, Michael