Sale Stock Quantity: Use the sale shipping date to calculate the forecast

Currently, the Sale Stock Quantity module displays a warning or an error message in case of quantity smaller than the forecast. But the module only uses the “Sale Date” in the context of calculating the forecast.

If we create a sale on today’s date with a shipping date in the future. If we don’t have the stock available on the current date, the system gives a warning on the forecast, even if we have placed a shipment date in the future (even if you have stock in the forecast on the shipping date indicated)

The user must check with a “relate” on the products the stock forecast to pass above the warning.

The date of the sale must be dated the current date of the order and not in the future.

I think the “Sale Stock Quantity” module should use the “planned_shipping_date” from the sale module as the date of the forecast calculation.

Indeed the module was created before we have a shipping date on the sale line.
But it is not that simple because we must check that placing the order will not prevent any other shipment until the next supply (or at max date if there is no supply delay).
Also we must add other sales based on their shipping date and probably not restrict to a sale date before the current sale date.
The change must be done in such way that it does not kill the performance because there are potentially a different shipping date for every line. Also it should use the grouping by date to compute product by location instead of adding days one by one.