Improve issue8775 patch makeing it more generic and ensure that it will work on all clients.
This commit is contained in:
parent
55d815c945
commit
7807f7e182
|
@ -1,70 +1,91 @@
|
|||
diff -r 183e40c3a037 trytond/trytond/modules/stock/move.py
|
||||
--- a/trytond/trytond/modules/stock/move.py Tue Oct 29 10:51:12 2019 +0100
|
||||
+++ b/trytond/trytond/modules/stock/move.py Tue Oct 29 12:08:55 2019 +0100
|
||||
@@ -889,6 +889,7 @@
|
||||
diff -r f3de4ca13568 move.py
|
||||
--- a/trytond/trytond/modules/stock/move.py Thu Oct 31 08:46:27 2019 +0100
|
||||
+++ b/trytond/trytond/modules/stock/move.py Thu Oct 31 09:00:13 2019 +0100
|
||||
@@ -892,6 +892,9 @@
|
||||
first = False
|
||||
else:
|
||||
with Transaction().set_context(_stock_move_split=True):
|
||||
+ values.update({'origin': 'stock.move,%s' % move.origin.id})
|
||||
+ if move.origin and isinstance(move.origin, cls):
|
||||
+ values.update({'origin': "stock.move,%s" %
|
||||
+ move.origin.id})
|
||||
to_assign.extend(cls.copy([move], default=values))
|
||||
|
||||
|
||||
qty_default_uom = Uom.compute_qty(move.uom, qty,
|
||||
diff -r 183e40c3a037 trytond/trytond/modules/stock/shipment.py
|
||||
--- a/trytond/trytond/modules/stock/shipment.py Tue Oct 29 10:51:12 2019 +0100
|
||||
+++ b/trytond/trytond/modules/stock/shipment.py Tue Oct 29 12:08:55 2019 +0100
|
||||
@@ -1177,8 +1177,8 @@
|
||||
diff -r f3de4ca13568 shipment.py
|
||||
--- a/trytond/trytond/modules/stock/shipment.py Thu Oct 31 08:46:27 2019 +0100
|
||||
+++ b/trytond/trytond/modules/stock/shipment.py Thu Oct 31 09:00:13 2019 +0100
|
||||
@@ -1166,6 +1166,9 @@
|
||||
pool = Pool()
|
||||
Move = pool.get('stock.move')
|
||||
Uom = pool.get('product.uom')
|
||||
+ origins = Move._get_origin()
|
||||
+ keep_origin = True if 'stock.move' in origins else False
|
||||
+
|
||||
for shipment in shipments:
|
||||
if shipment.warehouse_storage == shipment.warehouse_output:
|
||||
# Do not create inventory moves
|
||||
@@ -1175,30 +1178,34 @@
|
||||
for move in shipment.outgoing_moves:
|
||||
if move.state == 'cancel':
|
||||
continue
|
||||
+ key = ((move.product.id, move) if keep_origin
|
||||
+ else move.product.id)
|
||||
quantity = Uom.compute_qty(move.uom, move.quantity,
|
||||
move.product.default_uom, round=False)
|
||||
- outgoing_qty.setdefault(move.product.id, 0.0)
|
||||
- outgoing_qty[move.product.id] += quantity
|
||||
+ outgoing_qty.setdefault((move.product.id, move), 0.0)
|
||||
+ outgoing_qty[(move.product.id, move)] += quantity
|
||||
|
||||
+ outgoing_qty.setdefault(key, 0.0)
|
||||
+ outgoing_qty[key] += quantity
|
||||
|
||||
to_create = []
|
||||
for move in shipment.inventory_moves:
|
||||
@@ -1187,18 +1187,18 @@
|
||||
if move.state == 'cancel':
|
||||
continue
|
||||
+ key = ((move.product.id, move.origin) if keep_origin
|
||||
+ else move.product.id)
|
||||
qty_default_uom = Uom.compute_qty(move.uom, move.quantity,
|
||||
move.product.default_uom, round=False)
|
||||
# Check if the outgoing move doesn't exist already
|
||||
- if outgoing_qty.get(move.product.id):
|
||||
+ if outgoing_qty.get((move.product.id, move.origin)):
|
||||
+ if outgoing_qty.get(key):
|
||||
# If it exist, decrease the sum
|
||||
- if qty_default_uom <= outgoing_qty[move.product.id]:
|
||||
- outgoing_qty[move.product.id] -= qty_default_uom
|
||||
+ if qty_default_uom <= outgoing_qty[(move.product.id, move.origin)]:
|
||||
+ outgoing_qty[(move.product.id, move.origin)] -= qty_default_uom
|
||||
+ if qty_default_uom <= outgoing_qty[key]:
|
||||
+ outgoing_qty[key] -= qty_default_uom
|
||||
continue
|
||||
# Else create the complement
|
||||
else:
|
||||
out_quantity = (qty_default_uom
|
||||
- - outgoing_qty[move.product.id])
|
||||
+ - outgoing_qty[(move.product.id, move.origin)])
|
||||
+ - outgoing_qty[key])
|
||||
out_quantity = Uom.compute_qty(
|
||||
move.product.default_uom, out_quantity, move.uom)
|
||||
- outgoing_qty[move.product.id] = 0.0
|
||||
+ outgoing_qty[(move.product.id, move.origin)] = 0.0
|
||||
+ outgoing_qty[key] = 0.0
|
||||
else:
|
||||
out_quantity = move.quantity
|
||||
|
||||
@@ -1216,9 +1216,9 @@
|
||||
|
||||
@@ -1216,9 +1223,11 @@
|
||||
for move in shipment.outgoing_moves:
|
||||
if move.state == 'cancel':
|
||||
continue
|
||||
- if outgoing_qty.get(move.product.id, 0.0) > 0.0:
|
||||
+ if outgoing_qty.get((move.product.id, move), 0.0) > 0.0:
|
||||
+ key = ((move.product.id, move) if keep_origin
|
||||
+ else move.product.id)
|
||||
+ if outgoing_qty.get(key, 0.0) > 0.0:
|
||||
exc_qty = Uom.compute_qty(move.product.default_uom,
|
||||
- outgoing_qty[move.product.id], move.uom)
|
||||
+ outgoing_qty[(move.product.id, move)], move.uom)
|
||||
+ outgoing_qty[key], move.uom)
|
||||
removed_qty = Uom.compute_qty(move.uom,
|
||||
min(exc_qty, move.quantity), move.product.default_uom,
|
||||
round=False)
|
||||
@@ -1228,7 +1228,7 @@
|
||||
@@ -1228,7 +1237,7 @@
|
||||
0.0,
|
||||
move.uom.round(move.quantity - exc_qty)),
|
||||
})
|
||||
- outgoing_qty[move.product.id] -= removed_qty
|
||||
+ outgoing_qty[(move.product.id, move)] -= removed_qty
|
||||
|
||||
+ outgoing_qty[key] -= removed_qty
|
||||
|
||||
@classmethod
|
||||
@ModelView.button
|
||||
|
|
Loading…
Reference in New Issue