Issue 11140

Title
Object of type set is not JSON serializable error in processing sale order
Priority
bug
Status
resolved
Nosy list
booraa0a, ced, pokoli, reviewbot, roundup-bot
Assigned to
ced
Keywords
review

Created on 2022-01-16.17:42:38 by booraa0a, last changed 1 month ago by roundup-bot.

Messages

New changeset 0dbe01fd2e53 by Cédric Krier in branch '6.2':
Store list instead of set in context
https://hg.tryton.org/modules/sale_shipment_cost/rev/0dbe01fd2e53
New changeset 597effbb46fa by Cédric Krier in branch 'default':
Store list instead of set in context
https://hg.tryton.org/tryton-env/rev/597effbb46fa
New changeset be516fcc92bc by Cédric Krier in branch 'default':
Store list instead of set in context
https://hg.tryton.org/modules/sale_shipment_cost/rev/be516fcc92bc
Author: [hidden] (booraa0a)
Date: 2022-01-17.18:06:17

"How you setup the trigger?
It may be related to a wrong trigger definition."

Type: On Write
Model: Invoice
Condition : Equal(Get(Eval('self', {}), 'state', ''), 'validated')

The trigger is working and have no issue if I working with invoices directly.

Thank you.

Author: [hidden] (ced) Tryton committer Tryton translator
Date: 2022-01-17.16:21:53

Indeed we could use a dict with only keys and values set to None. This way we keep the fast index for contains operator.

Author: [hidden] (ced) Tryton committer Tryton translator
Date: 2022-01-17.09:45:18

I suspect it is the _shipment_cost_invoiced set puts in the context that is not serializable for the queue.
I guess we must use a list even if it will be less efficient.

Author: [hidden] (pokoli) Tryton committer Tryton translator
Date: 2022-01-17.09:30:33

How you setup the trigger?
It may be related to a wrong trigger definition.

Author: [hidden] (booraa0a)
Date: 2022-01-17.00:55:45

The below error only shows when there is a trigger on invoice model (for example create trigger type )

Author: [hidden] (booraa0a)
Date: 2022-01-16.17:42:38

I am using version 6.2.0.

Traceback (most recent call last):
  File "/trytond/wsgi.py", line 117, in dispatch_request
    return endpoint(request, **request.view_args)
  File "/trytond/protocols/dispatcher.py", line 46, in rpc
    return methods.get(request.rpc_method, _dispatch)(
  File "/trytond/wsgi.py", line 84, in auth_required
    return wrapped(*args, **kwargs)
  File "/trytond/protocols/wrappers.py", line 159, in wrapper
    return func(request, pool, *args, **kwargs)
  File "/trytond/protocols/dispatcher.py", line 180, in _dispatch
    result = rpc.result(meth(*c_args, **c_kwargs))
  File "/trytond/model/modelview.py", line 774, in wrapper
    return func(cls, records, *args, **kwargs)
  File "/trytond/modules/sale_shipment_cost/sale.py", line 216, in process
    super().process(sales)
  File "/trytond/model/modelview.py", line 774, in wrapper
    return func(cls, records, *args, **kwargs)
  File "/trytond/modules/sale/sale.py", line 958, in process
    cls._process_invoice(sales)
  File "/trytond/modules/sale/sale.py", line 970, in _process_invoice
    invoice = sale.create_invoice()
  File "/trytond/modules/sale_advance_payment/sale.py", line 405, in create_invoice
    invoice = super(Sale, self).create_invoice()
  File "/trytond/modules/commission/sale.py", line 28, in create_invoice
    invoice.save()
  File "/trytond/model/descriptors.py", line 31, in newfunc
    return self.func(owner, [instance], *args, **kwargs)
  File "/trytond/model/modelstorage.py", line 1853, in save
    cls.write(*sum(
  File "/trytond/modules/account_invoice/invoice.py", line 1250, in write
    super(Invoice, cls).write(*args)
  File "/trytond/model/modelsql.py", line 159, in wrapper
    return func(cls, *args, **kwargs)
  File "/trytond/model/modelsql.py", line 1084, in write
    cls.trigger_write(trigger_eligibles)
  File "/trytond/model/modelstorage.py", line 90, in wrapper
    return func(*args, **kwargs)
  File "/trytond/model/modelstorage.py", line 283, in trigger_write
    trigger.queue_trigger_action(records)
  File "/trytond/ir/trigger.py", line 194, in queue_trigger_action
    self.__class__.__queue__.trigger_action(self, list(ids))
  File "/trytond/ir/queue.py", line 241, in __call__
    return self.__queue.push(
  File "/trytond/ir/queue.py", line 70, in push
    record, = cls.create([{
  File "/trytond/model/modelsql.py", line 159, in wrapper
    return func(cls, *args, **kwargs)
  File "/trytond/model/modelsql.py", line 621, in create
    insert_values.append(field.sql_format(value))
  File "/trytond/model/fields/dict.py", line 61, in sql_format
    value = dumps(d)
  File "/json/__init__.py", line 234, in dumps
    return cls(
  File "/json/encoder.py", line 199, in encode
    chunks = self.iterencode(o, _one_shot=True)
  File "/json/encoder.py", line 257, in iterencode
    return _iterencode(o, 0)
  File "/trytond/protocols/jsonrpc.py", line 68, in default
    return marshaller(obj)
  File "/json/encoder.py", line 179, in default
    raise TypeError(f'Object of type {o.__class__.__name__} '
TypeError: Object of type set is not JSON serializable
History
Date User Action Args
2022-04-14 23:59:38roundup-botsetkeyword: - backport
messages: + msg75784
2022-04-03 23:59:16roundup-botsetmessages: + msg74952
2022-04-03 23:59:09roundup-botsetmessages: + msg74951
nosy: + roundup-bot
status: testing -> resolved
2022-03-26 01:06:26reviewbotsetmessages: + msg74765
nosy: + reviewbot
2022-03-26 00:58:23cedsetassignedto: ced
keyword: + backport, review
reviews: 393951002
status: chatting -> testing
2022-01-17 18:06:17booraa0asetmessages: + msg73264
2022-01-17 16:21:53cedsetmessages: + msg73262
2022-01-17 09:45:18cedsetmessages: + msg73258
nosy: + ced
status: need-eg -> chatting
2022-01-17 09:30:33pokolisetmessages: + msg73257
nosy: + pokoli
status: unread -> need-eg
2022-01-17 00:55:45booraa0asetcomponent: + trytond
messages: + msg73256

Showing 10 items. Show all history (warning: this could be VERY long)