Message 63878

Message id


In case the domain on a reference field has been computed by the domain inversion process a crash will occurs because the search reference a field that might not exist in the model.

Here's the traceback I got when reproducing it on a toy module made on purpose.

68158 140009424287488 [2021-01-13 18:05:52,487] ERROR trytond.protocols.dispatcher <class ''>.search(*(['AND', ['reference', '=', ',50'], ['reference', '=', ',50']], 0, 1000, None, {'client': 'd5e8f533-1abe-4487-a854-5977db4b94fc', 'language': 'en', 'language_direction': 'ltr', 'groups': [1]}), **{}) from <admin@>/reference_domain/
Traceback (most recent call last):
  File "/home/nicoe/projets/tryton/tryton-env/RefrenceFieldDomain/trytond/trytond/protocols/", line 181, in _dispatch
    result = rpc.result(meth(*c_args, **c_kwargs))
  File "/home/nicoe/projets/tryton/tryton-env/RefrenceFieldDomain/trytond/trytond/ir/ui/", line 134, in search
    menus = super(UIMenu, cls).search(domain, offset=offset, limit=limit,
  File "/home/nicoe/projets/tryton/tryton-env/RefrenceFieldDomain/trytond/trytond/model/", line 1263, in search
    tables, expression = cls.search_domain(domain)
  File "/home/nicoe/projets/tryton/tryton-env/RefrenceFieldDomain/trytond/trytond/model/", line 1449, in search_domain
    expression = convert(domain)
  File "/home/nicoe/projets/tryton/tryton-env/RefrenceFieldDomain/trytond/trytond/model/", line 1446, in convert
    return And((convert(d) for d in (
  File "/home/nicoe/projets/tryton/tryton-env/RefrenceFieldDomain/trytond/trytond/model/", line 1446, in <genexpr>
    return And((convert(d) for d in (
  File "/home/nicoe/projets/tryton/tryton-env/RefrenceFieldDomain/trytond/trytond/model/", line 1436, in convert
    field = cls._fields[fname]
KeyError: 'reference'

What happens is that the domain sent by the client do not take into account the fact that it will make a search on the model selected in the reference field. Thus the domain should not be ['reference', '=', ',50'] but ['id', '=', 50] (note also that the clause is repeated which I did not investigate yet).

Date User Action Args
2021-01-14 11:24:57nicoesetmessageid: <>
2021-01-14 11:24:57nicoelinkissue9997 messages
2021-01-14 11:24:57nicoecreate

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