2017-07-14 13:38:50 +02:00
|
|
|
diff -r 38eee3346e87 trytond/trytond/modules/stock/move.py
|
|
|
|
--- a/trytond/trytond/modules/stock/move.py Fri Jul 14 13:23:56 2017 +0200
|
|
|
|
+++ b/trytond/trytond/modules/stock/move.py Fri Jul 14 13:35:06 2017 +0200
|
|
|
|
@@ -675,7 +675,12 @@
|
|
|
|
|
2015-11-23 18:13:14 +01:00
|
|
|
@classmethod
|
|
|
|
def write(cls, *args):
|
|
|
|
+ pool = Pool()
|
|
|
|
+ Product = pool.get('product.product')
|
|
|
|
+ Uom = pool.get('product.uom')
|
|
|
|
+
|
|
|
|
actions = iter(args)
|
|
|
|
+ args = []
|
|
|
|
for moves, values in zip(actions, actions):
|
|
|
|
vals_set = set(values)
|
|
|
|
if cls._deny_modify_assigned & vals_set:
|
2017-07-14 13:38:50 +02:00
|
|
|
@@ -687,6 +692,27 @@
|
2015-11-23 18:13:14 +01:00
|
|
|
if move.state in ('done', 'cancel'):
|
|
|
|
cls.raise_user_error('modify_done_cancel',
|
|
|
|
(move.rec_name,))
|
|
|
|
+ if set(['quantity', 'uom', 'product']) & vals_set:
|
|
|
|
+ int_qty2moves = {}
|
|
|
|
+ for move in moves:
|
|
|
|
+ uom = values.get('uom', move.uom)
|
|
|
|
+ if not isinstance(uom, Uom):
|
|
|
|
+ uom = Uom(uom)
|
|
|
|
+ product = values.get('product', move.product)
|
|
|
|
+ if not isinstance(product, Uom):
|
|
|
|
+ product = Product(product)
|
|
|
|
+ internal_quantity = cls._get_internal_quantity(
|
|
|
|
+ values.get('quantity', move.quantity),
|
|
|
|
+ uom,
|
|
|
|
+ product)
|
|
|
|
+ int_qty2moves.setdefault(
|
|
|
|
+ internal_quantity, []).append(move)
|
|
|
|
+ for int_qty, int_qty_moves in int_qty2moves.iteritems():
|
|
|
|
+ new_values = values.copy()
|
|
|
|
+ new_values['internal_quantity'] = int_qty
|
|
|
|
+ args.extend((int_qty_moves, new_values))
|
|
|
|
+ else:
|
|
|
|
+ args.extend((moves, values))
|
2017-07-14 13:38:50 +02:00
|
|
|
|
2015-11-23 18:13:14 +01:00
|
|
|
super(Move, cls).write(*args)
|
2017-07-14 13:38:50 +02:00
|
|
|
|
|
|
|
@@ -694,15 +720,6 @@
|
2015-11-23 18:13:14 +01:00
|
|
|
for moves, values in zip(actions, actions):
|
|
|
|
if any(f not in cls._allow_modify_closed_period for f in values):
|
|
|
|
cls.check_period_closed(moves)
|
|
|
|
- for move in moves:
|
|
|
|
- internal_quantity = cls._get_internal_quantity(move.quantity,
|
|
|
|
- move.uom, move.product)
|
|
|
|
- if (internal_quantity != move.internal_quantity
|
|
|
|
- and internal_quantity
|
|
|
|
- != values.get('internal_quantity')):
|
|
|
|
- cls.write([move], {
|
|
|
|
- 'internal_quantity': internal_quantity,
|
|
|
|
- })
|
2017-07-14 13:38:50 +02:00
|
|
|
|
2015-11-23 18:13:14 +01:00
|
|
|
@classmethod
|
|
|
|
def delete(cls, moves):
|
2017-07-14 13:38:50 +02:00
|
|
|
diff -r 38eee3346e87 trytond/trytond/modules/stock/shipment.py
|
|
|
|
--- a/trytond/trytond/modules/stock/shipment.py Fri Jul 14 13:23:56 2017 +0200
|
|
|
|
+++ b/trytond/trytond/modules/stock/shipment.py Fri Jul 14 13:35:06 2017 +0200
|
|
|
|
@@ -1241,18 +1241,26 @@
|
2015-11-23 18:13:14 +01:00
|
|
|
Set planned date of moves for the shipments
|
|
|
|
'''
|
|
|
|
Move = Pool().get('stock.move')
|
|
|
|
+ to_write = []
|
|
|
|
for shipment in shipments:
|
|
|
|
outgoing_date, inventory_date = shipment._move_planned_date
|
|
|
|
- Move.write([x for x in shipment.outgoing_moves
|
|
|
|
+ out_moves_to_write = [x for x in shipment.outgoing_moves
|
|
|
|
if (x.state not in ('assigned', 'done', 'cancel')
|
|
|
|
- and x.planned_date != outgoing_date)], {
|
|
|
|
- 'planned_date': outgoing_date,
|
|
|
|
- })
|
|
|
|
- Move.write([x for x in shipment.inventory_moves
|
|
|
|
+ and x.planned_date != outgoing_date)]
|
|
|
|
+ if out_moves_to_write:
|
|
|
|
+ to_write.extend((out_moves_to_write, {
|
|
|
|
+ 'planned_date': outgoing_date,
|
|
|
|
+ }))
|
|
|
|
+
|
|
|
|
+ inv_moves_to_write = [x for x in shipment.inventory_moves
|
|
|
|
if (x.state not in ('assigned', 'done', 'cancel')
|
|
|
|
- and x.planned_date != inventory_date)], {
|
|
|
|
- 'planned_date': inventory_date,
|
|
|
|
- })
|
|
|
|
+ and x.planned_date != inventory_date)]
|
|
|
|
+ if inv_moves_to_write:
|
|
|
|
+ to_write.extend((inv_moves_to_write, {
|
|
|
|
+ 'planned_date': inventory_date,
|
|
|
|
+ }))
|
|
|
|
+ if to_write:
|
|
|
|
+ Move.write(*to_write)
|
2017-07-14 13:38:50 +02:00
|
|
|
|
2015-11-23 18:13:14 +01:00
|
|
|
@classmethod
|
|
|
|
def create(cls, vlist):
|