# Product Quantity in Sale Report

**URL:** https://discuss.tryton.org/t/product-quantity-in-sale-report/7550
**Category:** Developer
**Tags:** stock, sales
**Created:** [August 16, 2024, 9:58am UTC](https://discuss.tryton.org/t/product-quantity-in-sale-report/7550 "2024-08-16T09:58:30Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![jt93](https://discuss-cdn.tryton.org/letter_avatar_proxy/v4/letter/j/50afbb/32.png) [@jt93](https://discuss.tryton.org/u/jt93)
#### Post date: [August 16, 2024, 9:58am UTC](https://discuss.tryton.org/t/product-quantity-in-sale-report/7550/1 "2024-08-16T09:58:30Z")

</div>

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.

---

<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: [August 17, 2024, 6:39am UTC](https://discuss.tryton.org/t/product-quantity-in-sale-report/7550/2 "2024-08-17T06:39:15Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![jt93](https://discuss-cdn.tryton.org/letter_avatar_proxy/v4/letter/j/50afbb/32.png) [@jt93](https://discuss.tryton.org/u/jt93)
#### Post date: [August 19, 2024, 8:21am UTC](https://discuss.tryton.org/t/product-quantity-in-sale-report/7550/3 "2024-08-19T08:21:59Z")

</div>

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?

---

<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: [August 19, 2024, 9:17am UTC](https://discuss.tryton.org/t/product-quantity-in-sale-report/7550/4 "2024-08-19T09:17:41Z")

</div>

> [@jt93](#):
>
> Where would I add the `locations` to the `product` context? In the `get_context()` method of the sale report?

In the [context field](https://docs.tryton.org/latest/server/ref/fields.html#trytond.model.fields.Field.context)

---

<div class="post-metadata">

### Author: ![jt93](https://discuss-cdn.tryton.org/letter_avatar_proxy/v4/letter/j/50afbb/32.png) [@jt93](https://discuss.tryton.org/u/jt93)
#### Post date: [August 19, 2024, 11:47am UTC](https://discuss.tryton.org/t/product-quantity-in-sale-report/7550/5 "2024-08-19T11:47:19Z")

</div>

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