When calculating the stock quantity fields, we can put a from/to_date in the context. This should work in the past too. We see the to_date as the date in the past to calculate and calculate backwards from the stock now to the date in the past. This is done by doing an extra read_group on the stock moves, with a similar domain except that it takes the moves done from date_to.