Skip to content

[19.0][IMP] fs_attachments: fix parsing of stored filenames when storing locally#638

Open
CRogos wants to merge 1 commit into
OCA:19.0from
c4a8-odoo:19.0-imp-fs_attachments
Open

[19.0][IMP] fs_attachments: fix parsing of stored filenames when storing locally#638
CRogos wants to merge 1 commit into
OCA:19.0from
c4a8-odoo:19.0-imp-fs_attachments

Conversation

@CRogos

@CRogos CRogos commented Jul 3, 2026

Copy link
Copy Markdown
Contributor

Solves this error when new attachments should be stored locally:

RPC_ERROR

Odoo Server Error

Occured on c4a8-18-0-dev-34353123.dev.odoo.com on model hr.expense on 2026-07-03 09:32:36 GMT

Traceback (most recent call last):
  File "/home/odoo/src/odoo/odoo/http.py", line 2329, in _serve_db
    return service_model.retrying(serve_func, env=self.env)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/odoo/src/odoo/odoo/service/model.py", line 190, in retrying
    env.cr.flush()  # submit the changes to the database
    ^^^^^^^^^^^^^^
  File "/home/odoo/src/odoo/odoo/sql_db.py", line 182, in flush
    self.transaction.flush()
  File "/home/odoo/src/odoo/odoo/orm/environments.py", line 592, in flush
    self.default_env.flush_all()
  File "/home/odoo/src/odoo/odoo/orm/environments.py", line 383, in flush_all
    self._recompute_all()
  File "/home/odoo/src/odoo/odoo/orm/environments.py", line 376, in _recompute_all
    self[field.model_name]._recompute_field(field)
  File "/home/odoo/src/odoo/odoo/orm/models.py", line 6960, in _recompute_field
    field.recompute(records)
  File "/home/odoo/src/odoo/odoo/orm/fields.py", line 1891, in recompute
    apply_except_missing(self.compute_value, recs)
  File "/home/odoo/src/odoo/odoo/orm/fields.py", line 1861, in apply_except_missing
    func(records)
  File "/home/odoo/src/odoo/odoo/orm/fields.py", line 1915, in compute_value
    records._compute_field_value(self)
  File "/home/odoo/src/odoo/odoo/orm/models.py", line 4954, in _compute_field_value
    determine(field.compute, self)
  File "/home/odoo/src/odoo/odoo/orm/fields.py", line 81, in determine
    return needle(*args)
           ^^^^^^^^^^^^^
  File "/home/odoo/src/user/modules/oca/storage/fs_attachment/models/ir_attachment.py", line 114, in _compute_fs_url
    new_url = self.env["fs.storage"]._get_url_for_attachment(rec)
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/odoo/src/user/modules/oca/storage/fs_attachment/models/fs_storage.py", line 266, in _get_url_for_attachment
    _fs, storage_code, file_path = attachment._get_fs_parts()
                                   ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/odoo/src/user/modules/oca/storage/fs_attachment/models/ir_attachment.py", line 597, in _get_fs_parts
    return self._fs_parse_store_fname(self.store_fname)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/odoo/src/user/modules/oca/storage/fs_attachment/models/ir_attachment.py", line 527, in _fs_parse_store_fname
    fs = self._get_fs_storage_for_code(storage_code)
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/odoo/src/user/modules/oca/storage/fs_attachment/models/ir_attachment.py", line 509, in _get_fs_storage_for_code
    raise SystemError(f"No Filesystem storage for code {code}")
SystemError: No Filesystem storage for code 91/91e790cb58ba34fef3a9c34c15bdef1818b9c82b

The above server error caused the following client error:
RPC_ERROR: Odoo Server Error
    RPCError@https://c4a8-18-0-dev-34353123.dev.odoo.com/web/assets/094bae2/web.assets_web.min.js:3180:78
    makeErrorFromResponse@https://c4a8-18-0-dev-34353123.dev.odoo.com/web/assets/094bae2/web.assets_web.min.js:3184:165
    rpc._rpc/promise</<@https://c4a8-18-0-dev-34353123.dev.odoo.com/web/assets/094bae2/web.assets_web.min.js:3191:34
    

@OCA-git-bot

Copy link
Copy Markdown
Contributor

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

@CRogos CRogos force-pushed the 19.0-imp-fs_attachments branch from e71df9a to 9083b3f Compare July 3, 2026 10:02
@lmignon

lmignon commented Jul 3, 2026

Copy link
Copy Markdown
Contributor

@CRogos Can you explain your use case? I can't imagine the context in which you're encountering this problem. How can I reproduce your issue?

@CRogos

CRogos commented Jul 3, 2026

Copy link
Copy Markdown
Contributor Author

The error occurred when trying to post an expense in our staging system.

Because we don't want that any attachment of the production system is deleted by accident from the staging server, we replace the read/write credentials with with readonly credentials by an neutralize.sql script. We also deactivate that new attachments are uploaded to the cloud storage from the staging system, by removing all models from the fs.storage setting. Instead they are stored the usual odoo.sh way on the server. All attachments which were copied from the production system are still accessible by the readonly connection.

UPDATE fs_storage
      SET server_env_defaults = REPLACE(
          (
              SELECT value
                FROM ir_config_parameter
                WHERE key = 'c4a8_setting.fs_storage_env_azure_readonly'
          ),
          '"x_directory_path_env_default": ""',
          CONCAT('"x_directory_path_env_default": "', code, '"')
      )
      WHERE code like 'azure-%';

So the error occurs when the module is installed, but the new attachment is not stored in the cloud instead on the native story.

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.

3 participants