# Negative stock quantities after closing stock period

**URL:** https://discuss.tryton.org/t/negative-stock-quantities-after-closing-stock-period/9141
**Category:** User
**Tags:** stock
**Created:** [March 10, 2026, 8:47am UTC](https://discuss.tryton.org/t/negative-stock-quantities-after-closing-stock-period/9141 "2026-03-10T08:47:09Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![Xavi](https://discuss-cdn.tryton.org/letter_avatar_proxy/v4/letter/x/8e8cbc/32.png) [@Xavi](https://discuss.tryton.org/u/Xavi)
#### Post date: [March 10, 2026, 8:47am UTC](https://discuss.tryton.org/t/negative-stock-quantities-after-closing-stock-period/9141/1 "2026-03-10T08:47:09Z")

</div>

Hi,  
I’m running into an issue of negative quantities in some locations after closing a stock period.  
The day `12-02-2026` I’ve closed a stock period at date `31-12-2025`, I had locations with stock on them before the period date, which was moved after the period date, but before I’ve closed it, and those locations were deactivated, so, the stock they had `<=31-12-2025` is not inserted into `stock_period_cache`, but the stock coming from this locations is being computed.  
Is this the expected behaviour?  
To fix it, with a simple query I can find all the locations deactivated in that time, so I guess I can compute their stock at the period date and insert those values into the stock\_period\_cache table, but I would also like to know if there is better alternatives.  
Thanks in advance.

---

<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: [March 10, 2026, 9:18am UTC](https://discuss.tryton.org/t/negative-stock-quantities-after-closing-stock-period/9141/2 "2026-03-10T09:18:44Z")

</div>

> [@Xavi](#):
>
> I had locations with stock on them before the period date, which was moved after the period date, but before I’ve closed it, and those locations were deactivated, so, the stock they had `<=31-12-2025` is not inserted into `stock_period_cache`, but the stock coming from this locations is being computed.  
> Is this the expected behaviour?

No, it should not be possible to deactivate locations with stock. Even there is a [validation which prevents](https://foss.heptapod.net/tryton/tryton/-/blob/378a156b6625692113d80cd260a570f52bd44b48/modules/stock/location.py#L291) it.

For me you must check which locations are set as inactive, reactivat them and then simplify reopen and close the period again with the valid stock on it.

---

<div class="post-metadata">

### Author: ![Xavi](https://discuss-cdn.tryton.org/letter_avatar_proxy/v4/letter/x/8e8cbc/32.png) [@Xavi](https://discuss.tryton.org/u/Xavi)
#### Post date: [March 10, 2026, 9:25am UTC](https://discuss.tryton.org/t/negative-stock-quantities-after-closing-stock-period/9141/3 "2026-03-10T09:25:24Z")

</div>

> [@pokoli](#):
>
> No, it should not be possible to deactivate locations with stock. Even there is a [validation which prevents](https://foss.heptapod.net/tryton/tryton/-/blob/378a156b6625692113d80cd260a570f52bd44b48/modules/stock/location.py#L291) it.

I did not deactivated a location with stock, the location had stock, I’ve moved it, then I’ve deactivated it, the thing is, the location is currently deactivated, so it is being skipped in the` Period.close` function, but it was not deactivated and had stock at the date of the period I want to close.

---

<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: [March 10, 2026, 9:28am UTC](https://discuss.tryton.org/t/negative-stock-quantities-after-closing-stock-period/9141/4 "2026-03-10T09:28:28Z")

</div>

Then there is a bug in Tryton that should be reported and fixed. Could you please fill an [issue](https://bugs.tryton.org/)?

As we do not have a way to know if the location was active at the date where the period was closed probably we should compute the stock of a deactivated location when closing a period. It will be great if you can provide a fix and/or a test scenario.

---

<div class="post-metadata">

### Author: ![Xavi](https://discuss-cdn.tryton.org/letter_avatar_proxy/v4/letter/x/8e8cbc/32.png) [@Xavi](https://discuss.tryton.org/u/Xavi)
#### Post date: [March 10, 2026, 10:04am UTC](https://discuss.tryton.org/t/negative-stock-quantities-after-closing-stock-period/9141/5 "2026-03-10T10:04:43Z")

</div>

> **[Stock period closing does not take in count deactivated locations (#14664) ·...](https://foss.heptapod.net/tryton/tryton/-/issues/14664)**
>
> Following: https://discuss.tryton.org/t/negative-stock-quantities-after-closing-stock-period/9141/3 If a location is deactivated, it is not taken in count when closing a stock period, but the...
