Skip to content

[18.0][IMP] fs_attachment: improve attachment storage handling of files without body (size=0)#594

Draft
CRogos wants to merge 1 commit intoOCA:18.0from
c4a8-odoo:18.0-fix-fs_attachment
Draft

[18.0][IMP] fs_attachment: improve attachment storage handling of files without body (size=0)#594
CRogos wants to merge 1 commit intoOCA:18.0from
c4a8-odoo:18.0-fix-fs_attachment

Conversation

@CRogos
Copy link
Copy Markdown
Contributor

@CRogos CRogos commented Apr 21, 2026

Uploading an 0kb documents runs into this error. This also affects incoming mails with e.g. tracking images (helpdesk/vendorbills).

RPC_ERROR

Odoo Server Error

Occured on c4a8.odoo.com on model account.journal on 2026-04-21 13:36:19 GMT

Traceback (most recent call last):
  File "/home/odoo/src/odoo/odoo/http.py", line 2167, in _transactioning
    return service_model.retrying(func, env=self.env)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/odoo/src/odoo/odoo/service/model.py", line 157, in retrying
    result = func()
             ^^^^^^
  File "/home/odoo/src/odoo/odoo/http.py", line 2134, in _serve_ir_http
    response = self.dispatcher.dispatch(rule.endpoint, args)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/odoo/src/odoo/odoo/http.py", line 2382, in dispatch
    result = self.request.registry['ir.http']._dispatch(endpoint)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/odoo/src/odoo/odoo/addons/base/models/ir_http.py", line 333, in _dispatch
    result = endpoint(**request.params)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/odoo/src/odoo/odoo/http.py", line 754, in route_wrapper
    result = endpoint(self, *args, **params_ok)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/odoo/src/odoo/addons/web/controllers/dataset.py", line 36, in call_kw
    return call_kw(request.env[model], method, args, kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/odoo/src/odoo/odoo/api.py", line 535, in call_kw
    result = getattr(recs, name)(*args, **kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/odoo/src/enterprise/documents_account/models/account_journal.py", line 13, in create_document_from_attachment
    action = super().create_document_from_attachment(attachment_ids)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/odoo/src/enterprise/account_bank_statement_import/models/account_journal.py", line 31, in create_document_from_attachment
    return super().create_document_from_attachment(attachment_ids)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/odoo/src/odoo/addons/account/models/account_journal.py", line 988, in create_document_from_attachment
    invoices = self._create_document_from_attachment(attachment_ids)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/odoo/src/odoo/addons/account/models/account_journal.py", line 970, in _create_document_from_attachment
    invoice.with_context(skip_is_manually_modified=True)._extend_with_attachments(attachment, new=True)
  File "/home/odoo/src/odoo/addons/account/models/account_move.py", line 4344, in _extend_with_attachments
    file_data_list = attachments._unwrap_edi_attachments()
                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/odoo/src/odoo/addons/account/models/ir_attachment.py", line 159, in _unwrap_edi_attachments
    if supported_format['check'](attachment):
       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/odoo/src/odoo/addons/account/models/ir_attachment.py", line 120, in is_xml
    is_text_plain_xml = 'text/plain' in attachment.mimetype and (guess_mimetype(attachment.raw).endswith('/xml') or attachment.name.endswith('.xml'))
                                                                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/odoo/src/odoo/odoo/tools/mimetypes.py", line 205, in guess_mimetype
    mimetype = _guesser(bin_data[:MIMETYPE_HEAD_SIZE])
                        ~~~~~~~~^^^^^^^^^^^^^^^^^^^^^
TypeError: 'bool' object is not subscriptable

The above server error caused the following client error:
RPC_ERROR: Odoo Server Error
    RPC_ERROR
        at makeErrorFromResponse (https://c4a8.odoo.com/web/assets/4f873cc/web.assets_web.min.js:3178:165)
        at XMLHttpRequest.<anonymous> (https://c4a8.odoo.com/web/assets/4f873cc/web.assets_web.min.js:3184:13)

@OCA-git-bot
Copy link
Copy Markdown
Contributor

Hi @lmignon,
some modules you are maintaining are being modified, check this out!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants