details: https://code.tryton.org/tryton/commit/4b121694923d
branch: 8.2
user: Cédric Krier <[email protected]>
date: Tue Oct 13 18:53:13 2026 +0200
description:
Sum internal quantity to calculate the stock inventory reporting
The quantity is in the unit of the stock move which is not always the
same.
Closes #15166
(grafted from fb72b8d1cd1d3181935e6aff4e92dc4853af9ca9)
diffstat:
modules/stock/stock_reporting.py | 6 +++---
modules/stock/tests/scenario_stock_reporting_inventory.rst | 9 ++++++---
2 files changed, 9 insertions(+), 6 deletions(-)
diffs (53 lines):
diff -r 3a928c79607c -r 4b121694923d modules/stock/stock_reporting.py
--- a/modules/stock/stock_reporting.py Mon Oct 12 12:42:56 2026 +0200
+++ b/modules/stock/stock_reporting.py Tue Oct 13 18:53:13 2026 +0200
@@ -154,13 +154,13 @@
output_clause = (
(from_location.left >= left) & (from_location.right <= right))
start_quantity = Sum(
- move.quantity * Case((output_clause, -1), else_=1),
+ move.internal_quantity * Case((output_clause, -1), else_=1),
filter_=(move_date < from_date))
input_quantity = Sum(
- move.quantity,
+ move.internal_quantity,
filter_=input_clause & (move_date >= from_date))
output_quantity = Sum(
- move.quantity,
+ move.internal_quantity,
filter_=output_clause & (move_date >= from_date))
date_column = Greatest(move_date, from_date)
diff -r 3a928c79607c -r 4b121694923d
modules/stock/tests/scenario_stock_reporting_inventory.rst
--- a/modules/stock/tests/scenario_stock_reporting_inventory.rst Mon Oct
12 12:42:56 2026 +0200
+++ b/modules/stock/tests/scenario_stock_reporting_inventory.rst Tue Oct
13 18:53:13 2026 +0200
@@ -50,6 +50,8 @@
Create product::
>>> unit, = ProductUom.find([('name', '=', 'Unit')])
+ >>> box2, = unit.duplicate(default={'factor': 2, 'rate': .5})
+ >>> box10, = unit.duplicate(default={'factor': 10, 'rate': .1})
>>> template = ProductTemplate()
>>> template.name = 'Product'
@@ -96,8 +98,8 @@
>>> move.product = product
>>> move.from_location = storage_loc
>>> move.to_location = customer_loc
- >>> move.unit = unit
- >>> move.quantity = 2
+ >>> move.unit = box2
+ >>> move.quantity = 1
>>> move.effective_date = dt.date(2025, 1, 10)
>>> move.unit_price = Decimal('20.0000')
>>> move.currency = currency
@@ -111,7 +113,8 @@
>>> move.product = product
>>> move.from_location = supplier_loc
>>> move.to_location = storage_loc
- >>> move.quantity = 10
+ >>> move.unit = box10
+ >>> move.quantity = 1
>>> move.effective_date = dt.date(2025, 1, 5)
>>> move.unit_price = Decimal('10.0000')
>>> move.currency = currency