Error when try to create a Dict function field (Ko 4.8. Ok 3.8)

Working in 3.8:

esale_slug_langs = fields.Function(fields.Dict(None, 'Slug Langs'), 'get_esale_slug_langs')

def get_esale_slug_langs(self, name):
      return {'ca': 'demo', 'es': demo'}

Same code doesn’t work in 4.8. In GTK client I get message:

sequence item 1: expected string, NoneType found

I try to convert dict to string. I get an error because expect a dict field:

File “/home/resteve/tryton/tryton48/tryton/gui/window/view_form/view/form_gtk/”, line 542, in display
new_key_names = set(value.iterkeys()) - set(self.keys)
AttributeError: ‘unicode’ object has no attribute ‘iterkeys’

What am I doing wrong?

The second traceback is due to the string conversion, the clients expect the value as dict so you should not convert.

From the first traceback it seems that there is some None value that is read. Could you post the full traceback? Maybe it’s because you are using a None as Dictionary Schema, which IIRC is required on the client side to render the dictionary keys/values.


/home/resteve/tryton/tryton48/tryton/gui/window/view_form/view/form_gtk/ Warning: g_value_get_int: assertion ‘G_VALUE_HOLDS_INT (value)’ failed

sequence item 1: expected string, NoneType found


Traceback (most recent call last):
File “/trytond/”, line 71, in dispatch_request
return endpoint(request, **request.view_args)
File “/trytond/protocols/”, line 41, in rpc
request, database_name, *request.rpc_params)
File “/trytond/”, line 42, in auth_required
return wrapped(*args, **kwargs)
File “/trytond/protocols/”, line 122, in wrapper
return func(request, pool, *args, **kwargs)
File “/trytond/protocols/”, line 151, in _dispatch
obj, method = get_object_method(request, pool)
File “/trytond/protocols/”, line 126, in get_object_method
obj = pool.get(name, type=type)
File “/trytond/”, line 180, in get
return self._pool[self.database_name][type][name]
KeyError: u’null’

It’s a dict and same code from v3.8 that is working.

Clearly it can not work. As @pokoli said, it is not allowed to display Dict on a widget without a schema model. Maybe on older version the error was not that visible.