# Forbid negative quantities when closing stock period

**URL:** https://discuss.tryton.org/t/forbid-negative-quantities-when-closing-stock-period/4531
**Category:** Ideas
**Tags:** stock
**Created:** [August 12, 2021, 8:48am UTC](https://discuss.tryton.org/t/forbid-negative-quantities-when-closing-stock-period/4531 "2021-08-12T08:48:50Z")
**Posts on this page:** 8
**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: [August 12, 2021, 8:48am UTC](https://discuss.tryton.org/t/forbid-negative-quantities-when-closing-stock-period/4531/1 "2021-08-12T08:48:51Z")

</div>

Tryton allows to have negative quantites of stock, which we expect to be fixed latter by the user.  
For example, if the user is shipping a product which supplier shipment is not yet introduced on the system, the negative quantity will be fixed when the supplier shipment is introduction.

As at some point we expect to fix, I’m wondering if we should prevent to close a stock period with negative quantities for some grouping. This will raise the alarm for the user that was not aware that there where negative quantities, so we force them to fix them.

Does it sound reasonable?

---

<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 12, 2021, 8:51am UTC](https://discuss.tryton.org/t/forbid-negative-quantities-when-closing-stock-period/4531/2 "2021-08-12T08:51:30Z")

</div>

For consumable product it is expected to have negative quantities.  
Also some location type like the supplier is also expected to have negative quantities.  
So I would make only a warning and check only for storage location and for non-consumable product.

---

<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: [August 12, 2021, 9:24am UTC](https://discuss.tryton.org/t/forbid-negative-quantities-when-closing-stock-period/4531/3 "2021-08-12T09:24:30Z")

</div>

> [@ced](#):
>
> For consumable product it is expected to have negative quantities.  
> Also some location type like the supplier is also expected to have negative quantities.

Yes, that makes sense.

> [@ced](#):
>
> So I would make only a warning

I’m wondering which is the benefit of the warning. As we are just checking storage locations it is not phisically possible to have a negative quantity, so this is for sure an error that should be fixed.

Using an error instead of a warning will force the user to fix the value instead of delaying the fix to the future.

If the warning is skipped and there is quantity update for the product, the warning will re-raise on the next stock closings.

I consider this similar to the [validation of inactive accounts when closing a period](https://hg.tryton.org/modules/account/rev/53bc1131c00c).

---

<div class="post-metadata">

### Author: ![msabater](https://discuss-cdn.tryton.org/letter_avatar_proxy/v4/letter/m/a183cd/32.png) [@msabater](https://discuss.tryton.org/u/msabater)
#### Post date: [August 12, 2021, 10:46am UTC](https://discuss.tryton.org/t/forbid-negative-quantities-when-closing-stock-period/4531/4 "2021-08-12T10:46:05Z")

</div>

> [@pokoli](#):
>
> I’m wondering which is the benefit of the warning. As we are just checking storage locations it is not phisically possible to have a negative quantity, so this is for sure an error that should be fixed.
> 
> Using an error instead of a warning will force the user to fix the value instead of delaying the fix to the future.
> 
> If the warning is skipped and there is quantity update for the product, the warning will re-raise on the next stock closings.

Please note that there are scenarios where it is possible to have negative quantities that cannot be fixed at the moment of closing a stock period.

Some customers have several locations and the responsible of closing stock period may be a different person than the responsible of updating stock values in a warehouse. Then, it may be desirable to close a stock period with negative quantities.

There may be products that are acquired in non-exact or very large quantities, like grain or seeds. In that case, fixing stock issues may not be straightforward.

So for me, this feature should be configurable by location.

---

<div class="post-metadata">

### Author: ![SISalp](https://discuss-cdn.tryton.org/user_avatar/discuss.tryton.org/sisalp/32/200_2.png) [@SISalp](https://discuss.tryton.org/u/SISalp)
#### Post date: [August 12, 2021, 10:54am UTC](https://discuss.tryton.org/t/forbid-negative-quantities-when-closing-stock-period/4531/5 "2021-08-12T10:54:59Z")

</div>

why does it matter ?

---

<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 12, 2021, 10:57am UTC](https://discuss.tryton.org/t/forbid-negative-quantities-when-closing-stock-period/4531/6 "2021-08-12T10:57:14Z")

</div>

> [@pokoli](#):
>
> I’m wondering which is the benefit of the warning. As we are just checking storage locations it is not phisically possible to have a negative quantity, so this is for sure an error that should be fixed.

But user is not required to fix at the precis day it happened.

> [@pokoli](#):
>
> Using an error instead of a warning will force the user to fix the value instead of delaying the fix to the future.

Users are free to do what ever they want. Also I’m not sure that many will fix right away (he may not have enough information to fix it) but indeed they will just not close the period.

> [@pokoli](#):
>
> If the warning is skipped and there is quantity update for the product, the warning will re-raise on the next stock closings.

Yes this will be a good behavior to keep user warned about the problem.

> [@pokoli](#):
>
> I consider this similar to the [validation of inactive accounts when closing a period](https://hg.tryton.org/modules/account/rev/53bc1131c00c).

For me it is not at the same level as for accounting there is no return back if the fiscal year is locked.

> [@msabater](#):
>
> So for me, this feature should be configurable by location.

I do not see the point to make a configuration. It is always better to have non-negative value but as long as we just have a warning that user may skip, we do not prevent to close the period.

---

<div class="post-metadata">

### Author: ![msabater](https://discuss-cdn.tryton.org/letter_avatar_proxy/v4/letter/m/a183cd/32.png) [@msabater](https://discuss.tryton.org/u/msabater)
#### Post date: [August 12, 2021, 11:25am UTC](https://discuss.tryton.org/t/forbid-negative-quantities-when-closing-stock-period/4531/7 "2021-08-12T11:25:16Z")

</div>

> [@ced](#):
>
> I do not see the point to make a configuration. It is always better to have non-negative value but as long as we just have a warning that user may skip, we do not prevent to close the period.

It is not required if we have a warning. If the system blocks period closing, though, it should be necessary some configuration.

---

<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: [August 12, 2021, 12:24pm UTC](https://discuss.tryton.org/t/forbid-negative-quantities-when-closing-stock-period/4531/8 "2021-08-12T12:24:54Z")

</div>

> [@msabater](#):
>
> Some customers have several locations and the responsible of closing stock period may be a different person than the responsible of updating stock values in a warehouse. Then, it may be desirable to close a stock period with negative quantities.

Then it’s just a mather of asking the right person to fix the quantities before doing the closing.

> [@msabater](#):
>
> There may be products that are acquired in non-exact or very large quantities, like grain or seeds. In that case, fixing stock issues may not be straightforward.

Ok that make sense for me, so a warning should work for all cases.

> [@SISalp](#):
>
> why does it matter ?

As the quantities are used for the stock valuation (which affect accounting), I think it’s a good practice to make the user aware that there is something to be fixed.

It makes more sense with [Add wizard to account the stock valuation](https://discuss.tryton.org/t/add-wizard-to-account-the-stock-valuation/3415) because we require the user to close the stock period before creating the right stock moves.
