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


Commits:
2ede0c16 by Cédric Krier at 2022-12-18T15:40:10+01:00
Ignore explicitly stock moves for assignation

Closes #11945
- - - - -


1 changed file:

- modules/stock/shipment.py


Changes:

=====================================
modules/stock/shipment.py
=====================================
@@ -64,6 +64,6 @@
         cls.assign(shipments)
 
     @dualmethod
-    def assign_ignore(cls, shipments):
+    def assign_ignore(cls, shipments, moves=None):
         pool = Pool()
         Move = pool.get('stock.move')
@@ -68,8 +68,12 @@
         pool = Pool()
         Move = pool.get('stock.move')
-        Move.write([
-                m for s in shipments for m in s.assign_moves
-                if m.assignation_required
-                and m.state in {'staging', 'draft'}], {
+        assign_moves = {
+            m for s in shipments for m in s.assign_moves
+            if m.assignation_required and m.state in {'staging', 'draft'}}
+        if moves is None:
+            moves = list(assign_moves)
+        else:
+            moves = [m for m in moves if m in assign_moves]
+        Move.write(moves, {
                 'quantity': 0,
                 })
@@ -74,6 +78,12 @@
                 'quantity': 0,
                 })
-        cls.assign(shipments)
+        to_assign = [
+            s for s in shipments
+            if all(
+                m.state not in {'staging', 'draft'}
+                for m in s.assign_moves if m.assignation_required)]
+        if to_assign:
+            cls.assign(to_assign)
 
     @classmethod
     def _get_assign_domain(cls):
@@ -2856,7 +2866,7 @@
         return 'end'
 
     def transition_ignore(self):
-        self.record.assign_ignore()
+        self.record.assign_ignore(self.partial.moves)
         return 'end'
 
 



View it on Heptapod: 
https://foss.heptapod.net/tryton/tryton/-/commit/2ede0c16d70f7984ecce1833e01d5f8c5fa261f9

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


Reply via email to