Skip to content

spp_registry: decide the fate of the /mail/attachment/delete override (policy differs from stock Odoo 19) and finish its two placeholder tests #523

Description

@gonzalesedwin1123

Follow-up from #522 (fix for #419), out of that PR's scope.

The override

spp_registry/controllers/mail.py still overrides POST /mail/attachment/delete (SPPAttachmentController.mail_attachment_delete). Unlike the update_content sibling removed in #522, it does run on Odoo 19 — but it enforces a different policy from stock, so it cannot simply be deleted as redundant:

Gate
spp_registry override message author OR base.group_system, then ACLs (_delete_and_notify); portal/guest path via message author or a mail.compose.message access token
stock Odoo 19 (mail/controllers/attachment.py:98-108) ir.attachment._has_attachments_ownership([access_token]) = write access on the attachment OR a scoped attachment_ownership token

Example divergence: an internal user with write access on the attachment who is neither the message author nor group_system is refused by the override and allowed by stock. Conversely the override lets the message author delete an attachment they have no write access to only if ACLs then allow it. Whether OpenSPP wants the author-or-admin policy or Odoo's ownership policy is a decision, not a cleanup.

Also worth knowing when deciding: with update_content back to stock (#522), the web client's message Delete (removeParams, attachment_ids: []) makes _message_update_content call message.attachment_ids._delete_and_notify() directly (mail_thread.py ~5093), i.e. a message's attachments are removed without passing through this override. So the override only governs the standalone "remove attachment" action, not attachments dropped with their message.

Placeholder tests

spp_registry/tests/test_mail_controllers.py::TestMailAttachmentDeleteController still carries two skipTest placeholders:

  • test_author_can_delete_own_attachment — "fixture limitation": the attachment is created by admin, so the author's _delete_and_notify fails on ACL. Fix the fixture (post via message_post as the author, or create the attachment as the author) rather than skipping.
  • test_missing_attachment_returns_without_error — not implemented; should patch bus.bus._sendone and assert the ir.attachment/delete payload for a stale id.

Suggested resolution

  1. Decide policy (product/security call). If stock is acceptable → delete the override, drop its i18n string, and keep/rewrite the tests against stock like fix(registry): drop broken /mail/message/update_content override #522 did. If author-or-admin must stay → keep the override, document why in the module docstring, and finish the two tests.
  2. Either way, un-skip the two placeholders.

Refs: #419, #522.

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions