Error when cancelling customer shipment

Hi,

when I try to cancel a customer shipment I get the following error with tryton 7.4:

trytond/modules/stock_shipment_measurements/stock.py", line 182, in cancel
    if issubclass(move.shipment, MeasurementsMixin):
       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: issubclass() arg 1 must be a class

At first I thought its a small bug, but when I use type(move.shipment) instead to get the class, I get another error:

trytond/modules/stock_shipment_measurements/stock.py", line 185, in cancel
    Shipment.set_measurements(shipments)
  File "trytond/trytond/modules/stock_shipment_measurements/stock.py", line 318, in set_measurements
    cls.write(shipments, {})
  File "trytond/trytond/modules/stock/shipment.py", line 1779, in write
    super(ShipmentOut, cls).write(*args)
  File "trytond/trytond/model/modelsql.py", line 275, in wrapper
    return func(cls, *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "trytond/trytond/model/modelsql.py", line 1380, in write
    sum(((records, values) + args)[0:None:2], [])))
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: can only concatenate list (not "set") to list

Am I missing something here? Any help is appreciated.

Thanks

I guess you should use isinstance instead of isssubclass to fix it.

Could you please fill an issue in the bug tracker?
If you want to contribute the fix back to the project, make sure to read our how to develop page.

Thanks for your effort on this!

Thanks for your reply. Using isinstance() solves the first problem and I created an issue. However, the second problem appearing afterwards seems to be a bigger one. Could it be another Bug, or some wrong configuration on my side?

Thanks

In fully updated 7.4 I get the following while trying to delete a shipment that was created from sale:

Traceback (most recent call last):
  File "/trytond/wsgi.py", line 96, in dispatch_request
    return endpoint(request, **request.view_args)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/trytond/protocols/dispatcher.py", line 44, in rpc
    return methods.get(request.rpc_method, _dispatch)(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/trytond/wsgi.py", line 76, in wrapper
    return func(request, *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/trytond/protocols/wrappers.py", line 206, in wrapper
    result = func(request, pool, *args, **kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/trytond/protocols/dispatcher.py", line 216, in _dispatch
    result = rpc.result(meth(*c_args, **c_kwargs))
                        ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/trytond/modules/stock/shipment.py", line 1798, in delete
    cls.cancel(shipments)
  File "/trytond/model/modelview.py", line 764, in wrapper
    return func(cls, records, *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/trytond/modules/stock_shipment_measurements/stock.py", line 461, in wrapper
    result = func(cls, shipments, *args, **kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/trytond/model/workflow.py", line 37, in wrapper
    result = func(cls, filtered, *args, **kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/trytond/modules/stock_shipment_measurements/stock.py", line 563, in cancel
    super().cancel(shipments)
  File "/trytond/model/modelview.py", line 764, in wrapper
    return func(cls, records, *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/trytond/model/workflow.py", line 37, in wrapper
    result = func(cls, filtered, *args, **kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/trytond/modules/sale_shipment_cost/stock.py", line 242, in cancel
    super().cancel(shipments)
  File "/trytond/model/modelview.py", line 764, in wrapper
    return func(cls, records, *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/trytond/model/workflow.py", line 37, in wrapper
    result = func(cls, filtered, *args, **kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/trytond/modules/sale/stock.py", line 25, in wrapper
    func(cls, shipments)
  File "/trytond/modules/sale/stock.py", line 71, in cancel
    super(ShipmentOut, cls).cancel(shipments)
  File "/trytond/model/modelview.py", line 764, in wrapper
    return func(cls, records, *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/trytond/model/workflow.py", line 37, in wrapper
    result = func(cls, filtered, *args, **kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/trytond/modules/stock/shipment.py", line 1734, in cancel
    Move.cancel([m for s in shipments
  File "/trytond/model/modelview.py", line 764, in wrapper
    return func(cls, records, *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/trytond/model/workflow.py", line 37, in wrapper
    result = func(cls, filtered, *args, **kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/trytond/modules/stock_shipment_measurements/stock.py", line 182, in cancel
    if issubclass(move.shipment, MeasurementsMixin):
       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: issubclass() arg 1 must be a class

Fault: issubclass() arg 1 must be a class

PS: My temporary fix is to first delete the outgoing moves, then I successfully delete the shipment without a crash.

Tested on demo.tryton.org and I get the same crash after activating shipment measurements module.

@jt93 Do feel free to assign yourself to the issue I created.

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.