# Store supplier available quantity

**URL:** https://discuss.tryton.org/t/store-supplier-available-quantity/2796
**Category:** Feature
**Created:** [May 29, 2020, 9:17pm UTC](https://discuss.tryton.org/t/store-supplier-available-quantity/2796 "2020-05-29T21:17:22Z")
**Posts on this page:** 16
**Page:** 1

<div class="post-metadata">

### Author: ![pokoli](https://discuss-cdn.tryton.org/user_avatar/discuss.tryton.org/pokoli/32/22_2.png) [@pokoli](https://discuss.tryton.org/u/pokoli)
#### Post date: [May 29, 2020, 9:17pm UTC](https://discuss.tryton.org/t/store-supplier-available-quantity/2796/1 "2020-05-29T21:17:22Z")

</div>

## Rational

When using the sale\_supply (and specially sale\_supply\_drop\_shipment) it’s important to know which quantity of products is available on the supplier site as this information is useful to decide if a customer order can be satisfied before confirming it.

Normally the unique way to know if the information is available is asking the supplier but nowadays it is more common that suppliers expose this information to their customers (via web service or a file updated periodically, etc.).

## Proposal

On the product supplier table add the following fields:

- **Available Quantity** : Float to represent the quantity that the supplier is ready to sell.
- **Quantity Unit** : The unit of measure to represent this quantity available.

The requested quantity should be available on the find\_best\_supplier pattern, so if the supplier does not have enough available quantity to fulfill the request it should be skipped.

## Implementation

---

<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: [May 30, 2020, 7:33am UTC](https://discuss.tryton.org/t/store-supplier-available-quantity/2796/2 "2020-05-30T07:33:59Z")

</div>

As this depends on `sale_supply` (and probably `sale_stock_quantity`) I think this should be implemented in a third module.

> [@pokoli](#):
>
> On the product supplier table add the following fields

I do not like to add operational fields on a referential model.  
Also it will make no sense to have this field for a product supplier related to a template.  
I think this should be stored on a different table. We should probably allow to add extra criteria like tha country, the company etc.

> [@pokoli](#):
>
> The requested quantity should be available on the find\_best\_supplier pattern, so if the supplier does not have enought available quantity to fill the request it should be skipped.

I’m not sure it is a good way because if any supplier has enough quantity we need any way to get one any way. So for me, it is more about extending `sale_stock_quantity` to warn about shortage with the selected supplier.  
But we could have two pass on calling `find_best_supplier` one which exclude the supplier without enough and an second if none is found without caring about shortage.

---

<div class="post-metadata">

### Author: ![pokoli](https://discuss-cdn.tryton.org/user_avatar/discuss.tryton.org/pokoli/32/22_2.png) [@pokoli](https://discuss.tryton.org/u/pokoli)
#### Post date: [June 1, 2020, 6:42am UTC](https://discuss.tryton.org/t/store-supplier-available-quantity/2796/3 "2020-06-01T06:42:25Z")

</div>

> [@ced](#):
>
> As this depends on `sale_supply` (and probably `sale_stock_quantity` ) I think this should be implemented in a third module.

Then I will name it purchase\_supplier\_stock but add the dependency on sale\_supply and sale\_stock\_supply optional as there should be some users that whant to know the supplier quantity without purchasing on sale.

> [@ced](#):
>
> I think this should be stored on a different table. We should probably allow to add extra criteria like tha country, the company etc.

Makes sense to use a seaprate model. Then we can add a Functional field on product to compute the supplier availble quantity for product to sum the quantities of avialable criterias and use this check for sale\_stock\_quantity.

> [@ced](#):
>
> So for me, it is more about extending `sale_stock_quantity` to warn about shortage with the selected supplier.

There is no selected supplier on purchase so we must sum all the avaialble ones.

> [@ced](#):
>
> But we could have two pass on calling `find_best_supplier` one which exclude the supplier without enough and an second if none is found without caring about shortage.

Makes sense.

---

<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: [June 1, 2020, 6:51am UTC](https://discuss.tryton.org/t/store-supplier-available-quantity/2796/4 "2020-06-01T06:51:11Z")

</div>

> [@pokoli](#):
>
> There is no selected supplier on purchase so we must sum all the avaialble ones.

There should be one when supplied on sale.

---

<div class="post-metadata">

### Author: ![pokoli](https://discuss-cdn.tryton.org/user_avatar/discuss.tryton.org/pokoli/32/22_2.png) [@pokoli](https://discuss.tryton.org/u/pokoli)
#### Post date: [June 1, 2020, 1:57pm UTC](https://discuss.tryton.org/t/store-supplier-available-quantity/2796/5 "2020-06-01T13:57:57Z")

</div>

> [@ced](#):
>
> There should be one when supplied on sale.

Yes but this is after the sale is confired and the warning of sale\_stock\_quantity is raised after.

So I think we should include a field to show the supplier quantity per product and show it on the product list view so the user entering the sale order has this information available. And use this field to raise the warning.

---

<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: [June 1, 2020, 2:58pm UTC](https://discuss.tryton.org/t/store-supplier-available-quantity/2796/6 "2020-06-01T14:58:49Z")

</div>

> [@ced](#):
>
> I think this should be stored on a different table. We should probably allow to add extra criteria like tha country, the company etc.

I wonder if it would make sense to use stock.move and use a different location for each supplier warehouse.

---

<div class="post-metadata">

### Author: ![pokoli](https://discuss-cdn.tryton.org/user_avatar/discuss.tryton.org/pokoli/32/22_2.png) [@pokoli](https://discuss.tryton.org/u/pokoli)
#### Post date: [June 1, 2020, 3:14pm UTC](https://discuss.tryton.org/t/store-supplier-available-quantity/2796/7 "2020-06-01T15:14:59Z")

</div>

> [@albert](#):
>
> I wonder if it would make sense to use stock.move and use a different location for each supplier warehouse.

For me stock move is usefull for having all the history of moves of the companies, which is not the current case as we may be only interested on the last quantity of the supplier for each of it’s countries/warehouses, etc.

Also I do not think it’s a good idea to have on the same table the supplier stock our own stock history.

Which is the benefit of reusing the stock.move table?

---

<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: [June 1, 2020, 3:49pm UTC](https://discuss.tryton.org/t/store-supplier-available-quantity/2796/8 "2020-06-01T15:49:57Z")

</div>

> [@pokoli](#):
>
> For me stock move is usefull for having all the history of moves of the companies, which is not the current case as we may be only interested on the last quantity of the supplier for each of it’s countries/warehouses, etc.

I agree, that’s why we’ve also used a different table to handle this in other projects.

> [@pokoli](#):
>
> Which is the benefit of reusing the stock.move table?

It could handle lots out of the box. It would also show the supplier stock in the same screen that shows the stock of the product by location. Which could be useful.

---

<div class="post-metadata">

### Author: ![pokoli](https://discuss-cdn.tryton.org/user_avatar/discuss.tryton.org/pokoli/32/22_2.png) [@pokoli](https://discuss.tryton.org/u/pokoli)
#### Post date: [June 1, 2020, 5:05pm UTC](https://discuss.tryton.org/t/store-supplier-available-quantity/2796/9 "2020-06-01T17:05:08Z")

</div>

> [@albert](#):
>
> It could handle lots out of the box.

Why you need to know lots?

You will never know which lot is delivered until the goods leave the supplier warehouse so for me tracking the available lots is useless.

> [@albert](#):
>
> It would also show the supplier stock in the same screen that shows the stock of the product by location. Which could be useful.

For me we should avoid mixxin supplier quantities with own company quantities: Company products can be used inmediatly but in order to receive there may be some delivery time.

---

<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: [June 1, 2020, 8:58pm UTC](https://discuss.tryton.org/t/store-supplier-available-quantity/2796/10 "2020-06-01T20:58:57Z")

</div>

> [@pokoli](#):
>
> we should include a field to show the supplier quantity per product and show it on the product list view

I do not see how you would do that as a product may have multiple suppliers with each one a quantity.  
But this could be displayed on the product supplier list but I’m not sure it will be useful as the supplier is not chosen at that time.

---

<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: [June 1, 2020, 9:43pm UTC](https://discuss.tryton.org/t/store-supplier-available-quantity/2796/11 "2020-06-01T21:43:58Z")

</div>

> [@pokoli](#):
>
> Why you need to know lots?
> 
> You will never know which lot is delivered until the goods leave the supplier warehouse so for me tracking the available lots is useless.

Some businesses do work handling supplier lots in advance and purchase specific supplier lots.

> [@pokoli](#):
>
> For me we should avoid mixxin supplier quantities with own company quantities: Company products can be used inmediatly but in order to receive there may be some delivery time.

If the company owns several warehouses products may not be available immediately either, depending on where you need the goods. Tryton even allows you to configure the delay of moving goods from one location to the other.

---

<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: [June 1, 2020, 10:03pm UTC](https://discuss.tryton.org/t/store-supplier-available-quantity/2796/12 "2020-06-01T22:03:14Z")

</div>

For me, it makes no sense to manage supplier location like a warehouse. It is too much work and I doubt companies will have such detailed information about the supplier warehouse (like when stock decrease or increase etc.).

---

<div class="post-metadata">

### Author: ![pokoli](https://discuss-cdn.tryton.org/user_avatar/discuss.tryton.org/pokoli/32/22_2.png) [@pokoli](https://discuss.tryton.org/u/pokoli)
#### Post date: [June 2, 2020, 6:27am UTC](https://discuss.tryton.org/t/store-supplier-available-quantity/2796/13 "2020-06-02T06:27:47Z")

</div>

> [@ced](#):
>
> I do not see how you would do that as a product may have multiple suppliers with each one a quantity.

As tryton will create a single purchase for a single product I think it makes sense to pick the supplier with max quantity available. Companies should be allowed to customize the value of the field if they have a diferent behaviour.

> [@ced](#):
>
> But this could be displayed on the product supplier list but I’m not sure it will be useful as the supplier is not chosen at that time

The product supplier is not avaiable no sale (where you want to knwo the available quantity) so for me it does not make sense to include it as part of the view but the field can be used to raise the _sale\_stock\_quantity_ warning

---

<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: [June 2, 2020, 6:58am UTC](https://discuss.tryton.org/t/store-supplier-available-quantity/2796/14 "2020-06-02T06:58:28Z")

</div>

> [@pokoli](#):
>
> As tryton will create a single purchase for a single product I think it makes sense to pick the supplier with max quantity available.

I do not agree because the process may choose another supplier and then raise a warning.  
Also it may make believe that it is the maximum quantity allowed to be purchased when the purchase process could be split through multiple suppliers.

---

<div class="post-metadata">

### Author: ![pokoli](https://discuss-cdn.tryton.org/user_avatar/discuss.tryton.org/pokoli/32/22_2.png) [@pokoli](https://discuss.tryton.org/u/pokoli)
#### Post date: [June 7, 2020, 7:06pm UTC](https://discuss.tryton.org/t/store-supplier-available-quantity/2796/15 "2020-06-07T19:06:20Z")

</div>

Then it makes sense to sum the quantities of all the suppliers and let the user create all the required purhase request for them.

---

<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: [June 7, 2020, 8:44pm UTC](https://discuss.tryton.org/t/store-supplier-available-quantity/2796/16 "2020-06-07T20:44:22Z")

</div>

We do not support such workflow for now. As long as it is not supported, we should not display such sum to avoid leading users to wrong belief.
