Product Quantity in Sale Report

Hi,

In my report template I try to access a products quantity with <line.product.quantity> . However, it always shows zeros there, even if the product is in stock.
I traced down the problem to the stock/product/get_quantity() function, where location_ids = None. What could be the problem here?

Thanks for your help.

The locations key is not set for the product instance on product field of the sale line. So the quantity is not computed.
Only the search context has it set for the UI.

Of course you could also set locations to the product context but it was not done in standard for performance reason.

Also I found it strange to display the quantity in stock in a sale report.

That makes sense.
My intention was to include in a sale quotation if a product is currently available (not the exact quantity) and if not, how long it would take to restock. Does that make sense, or is there a better approach to add this information?

Where would I add the locations to the product context? In the get_context() method of the sale report?

In the context field

where exactly do you mean? sorry, for asking again, but I could not find any further information about that in the docs.