Issue 10240

Title
Selecting party without location defined crashes on shipments
Priority
bug
Status
chatting
Nosy list
albertca, ced
Assigned to
Keywords

Created on 2021-03-31.19:25:13 by albertca, last changed 2 weeks ago by pokoli.

Messages

Author: [hidden] (albertca) Tryton committer
Date: 2021-04-14.00:46:22

Sure. Here's one of the tracebacks:

Traceback (most recent call last):
  File "/usr/local/lib/python37/dist-packages/trytond/wsgipy", line 116, in dispatch_request
    return endpoint(request, **requestview_args)
  File "/usr/local/lib/python37/dist-packages/trytond/protocols/dispatcherpy", line 48, in rpc
    request, database_name, *requestrpc_params)
  File "/usr/local/lib/python37/dist-packages/trytond/wsgipy", line 83, in auth_required
    return wrapped(*args, **kwargs)
  File "/usr/local/lib/python37/dist-packages/trytond/protocols/wrapperspy", line 131, in wrapper
    return func(request, pool, *args, **kwargs)
  File "/usr/local/lib/python37/dist-packages/trytond/protocols/dispatcherpy", line 181, in _dispatch
    result = rpcresult(meth(*c_args, **c_kwargs))
  File "/usr/local/lib/python37/dist-packages/trytond/model/modelsqlpy", line 859, in read
    getter_results = fieldget(ids, cls, field_list, values=result)
  File "/usr/local/lib/python37/dist-packages/trytond/model/fields/functionpy", line 106, in get
    return dict((name, call(name)) for name in names)
  File "/usr/local/lib/python37/dist-packages/trytond/model/fields/functionpy", line 106, in <genexpr>
    return dict((name, call(name)) for name in names)
  File "/usr/local/lib/python37/dist-packages/trytond/model/fields/functionpy", line 101, in call
    return dict((rid, method(r, name)) for r in records)
  File "/usr/local/lib/python37/dist-packages/trytond/model/fields/functionpy", line 101, in <genexpr>
    return dict((rid, method(r, name)) for r in records)
  File "/usr/local/lib/python37/dist-packages/trytond/model/fields/fieldpy", line 123, in wrapper
    return func(self, *args, **kwargs)
  File "/usr/local/lib/python37/dist-packages/trytond/modules/stock/shipmentpy", line 271, in on_change_with_supplier_location
    return selfsuppliersupplier_locationid
AttributeError: 'NoneType' object has no attribute 'id'

And here the one with the on_change:

Traceback (most recent call last):
  File "/usr/local/lib/python37/dist-packages/trytond/wsgipy", line 116, in dispatch_request
    return endpoint(request, **requestview_args)
  File "/usr/local/lib/python37/dist-packages/trytond/protocols/dispatcherpy", line 48, in rpc
    request, database_name, *requestrpc_params)
  File "/usr/local/lib/python37/dist-packages/trytond/wsgipy", line 83, in auth_required
    return wrapped(*args, **kwargs)
  File "/usr/local/lib/python37/dist-packages/trytond/protocols/wrapperspy", line 131, in wrapper
    return func(request, pool, *args, **kwargs)
  File "/usr/local/lib/python37/dist-packages/trytond/protocols/dispatcherpy", line 186, in _dispatch
    result = rpcresult(meth(inst, *c_args, **c_kwargs))
  File "/usr/local/lib/python37/dist-packages/trytond/model/fields/fieldpy", line 123, in wrapper
    return func(self, *args, **kwargs)
  File "/usr/local/lib/python37/dist-packages/trytond/modules/stock/shipmentpy", line 271, in on_change_with_supplier_location
    return selfsuppliersupplier_locationid
AttributeError: 'NoneType' object has no attribute 'id'
Author: [hidden] (ced) Tryton committer Tryton translator
Date: 2021-04-14.00:29:59

Could you provide the traceback?

Author: [hidden] (albertca) Tryton committer
Date: 2021-03-31.19:33:41

No I realize that I mistakenly talked about on_change_supplier() but in fact the problem is in on_change_with_supplier_location() which is also the getter of the supplier_location function field. So showing the field and allow the user changing is not possible.

Also it is possible to make the application crash if the field supplier_location is removed after creating the shipment.

So I guess that on_change_with_supplier_location() should get the first location (of type 'supplier') it finds, if the party has none assigned.

Author: [hidden] (albertca) Tryton committer
Date: 2021-03-31.19:25:13

Supplier Location and Customer Location fields are not required in party form but on_change_supplier() on stock.shipment.in and on_change_customer() on stock.shipment.out and stock.shipment.out.return expect the field to be not null, and crash otherwise.

This can be checked by in the demo server by:

  • Go to Albright party and set both customer and supplier location to NULL
  • Create a supplier (or customer) shipment
  • Select the party

I'm not sure what is the best solution, because we cannot raise a UserError in the on_change.

So not sure if the best option is to add the location field in the shipment, so the user will not be able to save, and thus, can fix it.

Making the field required does not seem a proper solution as it is a MultiValue and thus may become NULL when creating a new party and use it in another company.

History
Date User Action Args
2021-04-24 21:45:06pokolisetstatus: need-eg -> chatting
2021-04-14 00:46:22albertcasetmessages: + msg66590
2021-04-14 00:29:59cedsetmessages: + msg66587
nosy: + ced
status: unread -> need-eg
2021-03-31 19:33:41albertcasetmessages: + msg65956
2021-03-31 19:25:13albertcacreate