changeset b5caa8be2061 in modules/stock_package:default
details: 
https://hg.tryton.org/modules/stock_package?cmd=changeset&node=b5caa8be2061
description:
        Filter out moves without quantity from package

        There is no point for the packager to package zero quantity of a 
product.

        issue11210
        review384291002
diffstat:

 CHANGELOG |   1 +
 stock.py  |  13 ++++++++++---
 2 files changed, 11 insertions(+), 3 deletions(-)

diffs (49 lines):

diff -r 80bfd2bd5d56 -r b5caa8be2061 CHANGELOG
--- a/CHANGELOG Thu Feb 03 23:05:47 2022 +0100
+++ b/CHANGELOG Sun Mar 06 18:17:01 2022 +0100
@@ -1,3 +1,4 @@
+* Filter out moves without quantity from package
 * Add support for Python 3.10
 * Remove support for Python 3.6
 
diff -r 80bfd2bd5d56 -r b5caa8be2061 stock.py
--- a/stock.py  Thu Feb 03 23:05:47 2022 +0100
+++ b/stock.py  Sun Mar 06 18:17:01 2022 +0100
@@ -125,6 +125,9 @@
             ('to_location.type', 'in', ['customer', 'supplier']),
             ('state', '!=', 'cancelled'),
             ],
+        filter=[
+            ('quantity', '!=', 0),
+            ],
         add_remove=[
             ('package', '=', None),
             ],
@@ -318,7 +321,7 @@
             if not shipment.packages:
                 continue
             length = sum(len(p.moves) for p in shipment.packages)
-            if len(list(shipment.packages_moves)) != length:
+            if len(shipment.packages_moves) != length:
                 raise PackageError(
                     gettext('stock_package.msg_package_mismatch',
                         shipment=shipment.rec_name))
@@ -359,7 +362,9 @@
 
     @property
     def packages_moves(self):
-        return (m for m in self.outgoing_moves if m.state != 'cancelled')
+        return [
+            m for m in self.outgoing_moves
+            if m.state != 'cancelled' and m.quantity]
 
     def _group_parcel_key(self, lines, line):
         try:
@@ -406,4 +411,6 @@
 
     @property
     def packages_moves(self):
-        return (m for m in self.moves if m.state != 'cancelled')
+        return [
+            m for m in self.moves
+            if m.state != 'cancelled' and m.quantity]

Reply via email to