Render letter report when user has not company in preferences
Version: 6.8
Scenario:
1- Login by user that has not a company in preferences. 2- Menu Party. Select a party. 3- Render Letter report:
Traceback (most recent call last):
File "/genshi/template/eval.py", line 301, in lookup_attr
val = getattr(obj, key)
^^^^^^^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'header'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/genshi/template/eval.py", line 307, in lookup_attr
val = obj[key]
~~~^^^^^
TypeError: 'NoneType' object is not subscriptable
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/trytond/wsgi.py", line 109, in dispatch_request
return endpoint(request, **request.view_args)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/trytond/protocols/dispatcher.py", line 43, in rpc
return methods.get(request.rpc_method, _dispatch)(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/trytond/wsgi.py", line 75, in wrapper
return func(request, *args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/trytond/protocols/wrappers.py", line 197, in wrapper
return func(request, pool, *args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/trytond/protocols/dispatcher.py", line 204, in _dispatch
result = rpc.result(meth(*c_args, **c_kwargs))
^^^^^^^^^^^^^^^^^^^^^^^^^
File "/trytond/modules/html_report/engine.py", line 522, in execute
return super().execute(ids, data)
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/trytond/modules/company/party.py", line 134, in execute
return super(LetterReport, cls).execute(ids, data)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/trytond/report/report.py", line 244, in execute
oext, content = cls._execute(
^^^^^^^^^^^^^
File "/trytond/report/report.py", line 265, in _execute
return cls.convert(action, cls.render(action, report_context))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/trytond/report/report.py", line 367, in render
data = template.generate(**report_context).render()
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/relatorio/templates/base.py", line 16, in render
return self.serializer(
^^^^^^^^^^^^^^^^
File "/relatorio/templates/opendocument.py", line 1157, in __call__
output_encode(
File "/genshi/output.py", line 60, in encode
for chunk in iterator:
File "/genshi/output.py", line 243, in __call__
for kind, data, pos in stream:
File "/genshi/output.py", line 674, in __call__
for kind, data, pos in stream:
File "/genshi/output.py", line 779, in __call__
for kind, data, pos in chain(stream, [(None, None, None)]):
File "/genshi/output.py", line 598, in __call__
for ev in stream:
File "/relatorio/templates/opendocument.py", line 1053, in __call__
for kind, data, pos in stream:
File "/genshi/filters/i18n.py", line 789, in __call__
for kind, data, pos in stream:
File "/genshi/template/base.py", line 641, in _include
for event in stream:
File "/genshi/template/markup.py", line 326, in _match
for event in stream:
File "/genshi/template/base.py", line 621, in _flatten
stream = _apply_directives(data[1], data[0], ctxt, vars)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/genshi/template/base.py", line 275, in _apply_directives
stream = directives[0](iter(stream), directives[1:], ctxt, **vars)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/genshi/template/directives.py", line 410, in __call__
value = _eval_expr(self.expr, ctxt, vars)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/genshi/template/base.py", line 290, in _eval_expr
retval = expr.evaluate(ctxt)
^^^^^^^^^^^^^^^^^^^
File "/genshi/template/eval.py", line 160, in evaluate
return eval(self.code, _globals, {'__data__': data})
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "<string>", line 218, in <Expression 'user.company.header'>
File "/genshi/template/eval.py", line 309, in lookup_attr
val = cls.undefined(key, owner=obj)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/genshi/template/eval.py", line 397, in undefined
raise UndefinedError(key, owner=owner)
genshi.template.eval.UndefinedError: None has no member named "header"