details: https://code.tryton.org/tryton/commit/f26641076fe7
branch: 7.4
user: Cédric Krier <[email protected]>
date: Fri Jan 02 13:11:49 2026 +0100
description:
Test products_by_location using the proper grouping IDs
When grouping by template, it is the template id that appears in the
result
instead of the product id.
Closes #14459
(grafted from d929198e2b79c780347de9c83b839e14441550ea)
diffstat:
modules/stock_lot_sled/tests/test_module.py | 40 ++++++++++++++++++----------
1 files changed, 25 insertions(+), 15 deletions(-)
diffs (84 lines):
diff -r 681333000c19 -r f26641076fe7 modules/stock_lot_sled/tests/test_module.py
--- a/modules/stock_lot_sled/tests/test_module.py Mon Dec 29 15:58:40
2025 +0100
+++ b/modules/stock_lot_sled/tests/test_module.py Fri Jan 02 13:11:49
2026 +0100
@@ -74,10 +74,10 @@
config = Config(1)
- empty = {}
- computed = {(storage.id, product.id): 5}
- delta = {(storage.id, product.id): -5}
- for context, result in [
+ empty = 0
+ computed = 5
+ delta = -5
+ for context, quantity in [
({'stock_date_end': datetime.date.min}, empty),
({'stock_date_end': today + datetime.timedelta(days=-1)},
empty),
@@ -114,34 +114,42 @@
]:
with Transaction().set_context(context=context,
locations=[storage.id]):
- quantity = Product.products_by_location(
+ quantities = Product.products_by_location(
[storage.id], grouping_filter=([product.id],))
- self.assertEqual(quantity, result,
+ self.assertEqual(
+ quantities[(storage.id, product.id)],
+ quantity,
msg='context: %s' % repr(context))
- quantity = Product.products_by_location(
+ quantities = Product.products_by_location(
[storage.id], grouping_filter=([product.id],),
with_childs=True)
- self.assertEqual(quantity, result,
+ self.assertEqual(
+ quantities[(storage.id, product.id)],
+ quantity,
msg='context: %s, with childs' % repr(context))
- quantity = Product.products_by_location(
+ quantities = Product.products_by_location(
[storage.id],
grouping=('product.template',),
grouping_filter=([product.template.id],),)
- self.assertEqual(quantity, result,
+ self.assertEqual(
+ quantities[(storage.id, product.template.id)],
+ quantity,
msg='template, context: %s' % repr(context))
- quantity = Product.products_by_location(
+ quantities = Product.products_by_location(
[storage.id],
grouping=('product.template',),
grouping_filter=([product.template.id],),
with_childs=True)
- self.assertEqual(quantity, result,
+ self.assertEqual(
+ quantities[(storage.id, product.template.id)],
+ quantity,
msg='template, context: %s, with_childs' %
repr(context))
- for context, delay, result in [
+ for context, delay, quantity in [
({'stock_date_end': datetime.date.min},
datetime.timedelta(days=-1), empty),
({'stock_date_end': datetime.date.max},
@@ -151,9 +159,11 @@
config.save()
with Transaction().set_context(context=context,
locations=[storage.id]):
- quantity = Product.products_by_location(
+ quantities = Product.products_by_location(
[storage.id], grouping_filter=([product.id],))
- self.assertEqual(quantity, result,
+ self.assertEqual(
+ quantities[(storage.id, product.id)],
+ quantity,
msg='context: %s; shelf_life_delay: %s' %
(repr(context), delay))