changeset 8f23ae5997bd in modules/stock_lot:default
details: https://hg.tryton.org/modules/stock_lot?cmd=changeset&node=8f23ae5997bd
description:
Add lot to assign criteria if not empty
issue10671
review363731002
diffstat:
CHANGELOG | 1 +
stock.py | 17 +++++++++++++++++
tests/test_stock_lot.py | 4 ++++
3 files changed, 22 insertions(+), 0 deletions(-)
diffs (47 lines):
diff -r 3eca574e3543 -r 8f23ae5997bd CHANGELOG
--- a/CHANGELOG Wed Apr 06 23:37:44 2022 +0200
+++ b/CHANGELOG Thu Apr 07 10:31:53 2022 +0200
@@ -1,3 +1,4 @@
+* Add lot to assign criteria if not empty
* Add lot traceability
* Add support for Python 3.10
* Remove support for Python 3.6
diff -r 3eca574e3543 -r 8f23ae5997bd stock.py
--- a/stock.py Wed Apr 06 23:37:44 2022 +0200
+++ b/stock.py Thu Apr 07 10:31:53 2022 +0200
@@ -434,6 +434,23 @@
for move in moves:
move.check_lot()
+ @classmethod
+ def assign_try(cls, moves, with_childs=True, grouping=('product',)):
+ if 'lot' not in grouping:
+ moves_with_lot, moves_without_lot = [], []
+ for move in moves:
+ if move.lot:
+ moves_with_lot.append(move)
+ else:
+ moves_without_lot.append(move)
+ success = super().assign_try(
+ moves_with_lot, with_childs, grouping=grouping + ('lot',))
+ success &= super().assign_try(
+ moves_without_lot, with_childs, grouping=grouping)
+ else:
+ success = super().assign_try(moves, with_childs, grouping)
+ return success
+
class MoveAddLots(Wizard):
"Add Lots"
diff -r 3eca574e3543 -r 8f23ae5997bd tests/test_stock_lot.py
--- a/tests/test_stock_lot.py Wed Apr 06 23:37:44 2022 +0200
+++ b/tests/test_stock_lot.py Thu Apr 07 10:31:53 2022 +0200
@@ -330,4 +330,8 @@
tearDown=doctest_teardown, encoding='utf-8',
checker=doctest_checker,
optionflags=doctest.REPORT_ONLY_FIRST_FAILURE))
+ suite.addTests(doctest.DocFileSuite('scenario_stock_lot_assign_try.rst',
+ tearDown=doctest_teardown, encoding='utf-8',
+ checker=doctest_checker,
+ optionflags=doctest.REPORT_ONLY_FIRST_FAILURE))
return suite