Backport sale-order-dates from v8

This brings in most of the changes from v8 regarding sale-order-dates.
Those changes have been incubating a very long time on our instance (since v5 days!).
As far as I know it should not break any other module.