OFX Statement Import fails on UTF-8 coded file containing german umlauts

Is this by design, that it is not possible to Import OFX-File in UTF-8 encoding containing german umlauts (äöü)?

Receiving camt.052 (XML) Bank which i convert to OFX using ofxconvert.
Resulting file is UTF-8 encoded containing some special chars (for exampel: Receiver of Payment “Finanzamt Mühlacker”).

Tried to check in Demo-System but module account-statement-ofx is not activated there.

Stack-Trace is as follows:

Traceback (most recent call last):
  File "/srv/tryton/edp60int/venv/lib/python37/site-packages/trytond/wsgipy", line 117, in dispatch_request
    return endpoint(request, **requestview_args)
  File "/srv/tryton/edp60int/venv/lib/python37/site-packages/trytond/protocols/dispatcherpy", line 48, in rpc
    request, database_name, *requestrpc_params)
  File "/srv/tryton/edp60int/venv/lib/python37/site-packages/trytond/wsgipy", line 84, in auth_required
    return wrapped(*args, **kwargs)
  File "/srv/tryton/edp60int/venv/lib/python37/site-packages/trytond/protocols/wrapperspy", line 156, in wrapper
    return func(request, pool, *args, **kwargs)
  File "/srv/tryton/edp60int/venv/lib/python37/site-packages/trytond/protocols/dispatcherpy", line 181, in _dispatch
    result = rpcresult(meth(*c_args, **c_kwargs))
  File "/srv/tryton/edp60int/venv/lib/python37/site-packages/trytond/wizard/wizardpy", line 314, in execute
    return wizard_execute(state_name)
  File "/srv/tryton/edp60int/venv/lib/python37/site-packages/trytond/wizard/wizardpy", line 340, in _execute
    do_result = do(action)
  File "/srv/tryton/edp60int/venv/lib/python37/site-packages/trytond/modules/account_statement/statementpy", line 1198, in do_import_
    statements = list(getattr(self, 'parse_%s' % selfstartfile_format)())
  File "/srv/tryton/edp60int/venv/lib/python37/site-packages/trytond/modules/account_statement_ofx/accountpy", line 27, in parse_ofx
    ofx = ofxparseOfxParserparse(file_)
  File "/srv/tryton/edp60int/venv/lib/python37/site-packages/ofxparse/ofxparsepy", line 387, in parse
    ofx_file = OfxPreprocessedFile(file_handle)
  File "/srv/tryton/edp60int/venv/lib/python37/site-packages/ofxparse/ofxparsepy", line 152, in __init__
    ofx_string = selffhread()
  File "/usr/lib/python37/codecspy", line 504, in read
    newchars, decodedbytes = selfdecode(data, selferrors)
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 806: ordinal not in range(128)

Anonymized OFX-File can be provided.


It looks like account_statement_ofx should use a StringIO instead of BytesIO because oxfparse seems to expect a a file object in text mode and not binary.
You should report a bug on https://bugs.tryton.org/

I’ve had a look into this and I think it might be an issue with the format of the OFX file, as I noted on Issue 10461: OFX Statement Import fails on UTF-8 encoded file containing german umlauts - Tryton issue tracker

@dave … can confirm. Removing the begin and end comment from ofx file solves my problem.

Further i’ve looked into source of package ofxstatement. Seems that there is no option to control the behavior of header creation.
Will submit bug report there.

Thanks for your fast response.

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.