Why is there a m2m relationship between stock.move and stock.forecast.line?

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).

For me as it is there since the initial commit, it is for historical reason. The One2Many based on Reference fields was implemented later.

Ok. Thanks.

I created Issue 9243: Use move's origin to link to forecast lines - Tryton issue tracker