Forecast lines may create stock moves and the relationship between them is handled using a m2m field:
https://hg.tryton.org/modules/stock_forecast/file/tip/forecast.py#l281
It seems to me that the existing origin Reference field in stock.move could be more appropriate.
Is there a reason that makes a m2m better in this case?
The reason I arrived here is that it performs much better creating stock moves at once rather than by filling the m2m (almost 40.000 moves take 60s vs 85s – with several other optimizations applied).