_set_transit may try to copy() an empty list
We received the traceback below from one of our customers.
Don't have a scenario to reproduce but it seems clear to me that changing the code in _set_transit should fix the issue and seems correct to me.
if m.state != 'done'
and m.from_location != shipment.transit_location
and m.to_location != shipment.transit_location]
+ if not moves:
+ continue
Move.copy(moves, default={
'to_location': shipment.transit_location.id,
'planned_date': shipment.planned_start_date,
Traceback (most recent call last):
File "/tryton/tryton/trytond/trytond/protocols/dispatcher.py", line 195, in _dispatch
result = rpc.result(meth(*c_args, **c_kwargs))
^^^^^^^^^^^^^^^^^^^^^^^^^
File "/tryton/tryton/trytond/trytond/model/modelview.py", line 697, in wrapper
return func(cls, records, *args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/tryton/tryton/trytond/trytond/model/workflow.py", line 37, in wrapper
result = func(cls, filtered, *args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/tryton/tryton/trytond/trytond/modules/stock/shipment.py", line 2550, in wait
cls._set_transit(shipments)
File "/tryton/tryton/trytond/trytond/modules/stock/shipment.py", line 2492, in _set_transit
Move.copy(moves, default={
File "/tryton/tryton/trytond/trytond/modules/account_stock_eu_es/stock.py", line 167, in copy
return super().copy(moves, default=default)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/tryton/tryton/trytond/trytond/modules/account_stock_eu/stock.py", line 547, in copy
return super().copy(moves, default=default)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/tryton/tryton/trytond/trytond/modules/account_stock_eu/stock.py", line 233, in copy
return super().copy(moves, default=default)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/tryton/tryton/trytond/trytond/modules/account_invoice_stock/stock.py", line 75, in copy
return super().copy(moves, default=default)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/tryton/tryton/trytond/trytond/model/workflow.py", line 58, in copy
return super().copy(records, default=default)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/tryton/tryton/trytond/trytond/model/modelstorage.py", line 481, in copy
cls.write(*to_write)
File "/tryton/tryton/trytond/trytond/modules/account_stock_eu/stock.py", line 215, in write
super().write(*args)
File "/tryton/tryton/trytond/trytond/modules/production/stock.py", line 99, in write
super().write(*args)
File "/tryton/tryton/trytond/trytond/modules/account_invoice_stock/stock.py", line 86, in write
super().write(*args)
File "/tryton/tryton/trytond/trytond/modules/stock_shipment_measurements/stock.py", line 146, in write
super(Move, cls).write(*args)
File "/tryton/tryton/trytond/trytond/modules/stock/move.py", line 838, in write
super(Move, cls).write(*args)
File "/tryton/tryton/trytond/trytond/model/modelsql.py", line 161, in wrapper
return func(cls, *args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: ModelSQL.write() missing 2 required positional arguments: 'records' and 'values'