Cédric Krier pushed to branch branch/default at Tryton / Tryton


Commits:
18b36a43 by Cédric Krier at 2022-12-29T19:07:56+01:00
Allow children location as source of outgoing moves for customer shipment

When the output location is the same as the storage location, we should allow
to record that products have been picked in a children location.

Closes #11973
- - - - -


1 changed file:

- modules/stock/shipment.py


Changes:

=====================================
modules/stock/shipment.py
=====================================
@@ -1081,7 +1081,10 @@
     outgoing_moves = fields.Function(fields.One2Many('stock.move', 'shipment',
             'Outgoing Moves',
             domain=[
-                ('from_location', '=', Eval('warehouse_output')),
+                If(Eval('warehouse_output') == Eval('warehouse_storage'),
+                    ('from_location', 'child_of',
+                        [Eval('warehouse_output', -1)], 'parent'),
+                    ('from_location', '=', Eval('warehouse_output'))),
                 If(~Eval('state').in_(['done', 'cancelled']),
                     ('to_location', '=', Eval('customer_location')),
                     ()),
@@ -1321,11 +1324,12 @@
             return self.customer.customer_location.id
 
     def get_outgoing_moves(self, name):
-        moves = []
-        for move in self.moves:
-            if move.from_location == self.warehouse_output:
-                moves.append(move.id)
-        return moves
+        if self.warehouse_output == self.warehouse_storage:
+            return [m.id for m in self.moves]
+        else:
+            return [
+                m.id for m in self.moves
+                if m.from_location == self.warehouse_output]
 
     @classmethod
     def set_outgoing_moves(cls, shipments, name, value):
@@ -1965,6 +1969,5 @@
             return self.customer.customer_location.id
 
     def get_incoming_moves(self, name):
-        moves = []
         if self.warehouse_input == self.warehouse_storage:
             return [m.id for m in self.moves]
@@ -1969,9 +1972,9 @@
         if self.warehouse_input == self.warehouse_storage:
             return [m.id for m in self.moves]
-        for move in self.moves:
-            if move.to_location == self.warehouse_input:
-                moves.append(move.id)
-        return moves
+        else:
+            return [
+                m.id for m in self.moves
+                if m.to_location == self.warehouse_input]
 
     @classmethod
     def set_incoming_moves(cls, shipments, name, value):



View it on Heptapod: 
https://foss.heptapod.net/tryton/tryton/-/commit/18b36a433c2019fdc719bd531742087da9071806

-- 
View it on Heptapod: 
https://foss.heptapod.net/tryton/tryton/-/commit/18b36a433c2019fdc719bd531742087da9071806
You're receiving this email because of your account on foss.heptapod.net.


Reply via email to