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

**URL:** <https://discuss.tryton.org/t/why-is-there-a-m2m-relationship-between-stock-move-and-stock-forecast-line/2610>\
**Category:** Developer\
**Created:** [April 19, 2020, 4:58pm UTC](https://discuss.tryton.org/t/why-is-there-a-m2m-relationship-between-stock-move-and-stock-forecast-line/2610 "2020-04-19T16:58:35Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![albert](https://discuss-cdn.tryton.org/user_avatar/discuss.tryton.org/albert/32/21_2.png) [@albert](https://discuss.tryton.org/u/albert)\
**Post date:** [April 19, 2020, 4:58pm UTC](https://discuss.tryton.org/t/why-is-there-a-m2m-relationship-between-stock-move-and-stock-forecast-line/2610/1 "2020-04-19T16:58:36Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![ced](https://discuss-cdn.tryton.org/user_avatar/discuss.tryton.org/ced/32/1237_2.png) [@ced](https://discuss.tryton.org/u/ced)\
**Post date:** [April 19, 2020, 9:00pm UTC](https://discuss.tryton.org/t/why-is-there-a-m2m-relationship-between-stock-move-and-stock-forecast-line/2610/2 "2020-04-19T21:00:29Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![albert](https://discuss-cdn.tryton.org/user_avatar/discuss.tryton.org/albert/32/21_2.png) [@albert](https://discuss.tryton.org/u/albert)\
**Post date:** [April 19, 2020, 9:52pm UTC](https://discuss.tryton.org/t/why-is-there-a-m2m-relationship-between-stock-move-and-stock-forecast-line/2610/3 "2020-04-19T21:52:24Z")

</div>

Ok. Thanks.

I created [Use move's origin to link to forecast lines (#9243) · Issues · Tryton / Tryton · GitLab](https://bugs.tryton.org/issue9243)
