Crash when login when have multicompany without parent
Afer #7116 (closed) "use recursive CTE when MPTT is not there", crash when login user with a multicompany scenario that the companies don't have parent (is null). Crash here [1]
Traceback (most recent call last):
File "/trytond/wsgi.py", line 71, in dispatch_request
return endpoint(request, **request.view_args)
File "/trytond/protocols/dispatcher.py", line 41, in rpc
request, database_name, *request.rpc_params)
File "/trytond/wsgi.py", line 42, in auth_required
return wrapped(*args, **kwargs)
File "/trytond/protocols/wrappers.py", line 122, in wrapper
return func(request, pool, *args, **kwargs)
File "/trytond/protocols/dispatcher.py", line 178, in _dispatch
result = rpc.result(meth(*c_args, **c_kwargs))
File "/trytond/res/user.py", line 509, in get_preferences
preferences = cls._get_preferences(user, context_only=context_only)
File "/trytond/modules/company/company.py", line 197, in _get_preferences
context_only=context_only)
File "/trytond/res/user.py", line 486, in _get_preferences
res[field] = getattr(user, field)
File "/trytond/model/fields/field.py", line 298, in __get__
return inst.__getattr__(self.name)
File "/trytond/model/modelstorage.py", line 1474, in __getattr__
read_data = self.read(list(ids), ffields.keys())
File "/trytond/modules/company/company.py", line 266, in read
('parent', 'child_of', [main_company_id]),
File "/trytond/model/modelsql.py", line 1191, in search
tables, expression = cls.search_domain(domain)
File "/trytond/model/modelsql.py", line 1375, in search_domain
expression = convert(domain)
File "/trytond/model/modelsql.py", line 1373, in convert
domain[1:] if domain[0] == 'AND' else domain)))
File "/trytond/model/modelsql.py", line 1372, in <genexpr>
return And((convert(d) for d in (
File "/trytond/model/modelsql.py", line 1363, in convert
expression = field.convert_domain(domain, tables, cls)
File "/trytond/model/fields/field.py", line 172, in wrapper
return func(*args, **kwargs)
File "/trytond/model/fields/many2one.py", line 206, in convert_domain
(name, operator, ids), tables)
File "/trytond/model/fields/many2one.py", line 143, in convert_domain_tree
red_sql = reduce_ids(target.id, ids)
File "/trytond/tools/misc.py", line 167, in reduce_ids
ids = map(int, ids)
TypeError: int() argument must be a string or a number, not 'NoneType'
[1] https://bitbucket.org/tryton/company/src/551a3f2d25d3f4d1feaa88ae613405bf1f68eefa/company.py#lines-259