fix(registry): drop broken /mail/message/update_content override - #522
Open
gonzalesedwin1123 wants to merge 4 commits into
Open
gonzalesedwin1123 wants to merge 4 commits into
gonzalesedwin1123 wants to merge 4 commits into
Conversation
Member
Author
Full
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## 19.0 #522 +/- ##
==========================================
- Coverage 76.91% 76.89% -0.02%
==========================================
Files 704 740 +36
Lines 45774 48004 +2230
==========================================
+ Hits 35205 36913 +1708
- Misses 10569 11091 +522
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
The override was ported from Odoo 17, where it was already redundant: stock 17 granted author-or-administrator editing too, and the override only narrowed "administrator" to base.group_system and answered with an AccessError instead of a 404. On Odoo 19 it never worked: it called the removed ir.attachment._check_attachments_access, expected the Odoo 17 request shape while the web client now sends update_data, and returned through the removed message_format(). Every chatter Edit/Delete errored. Stock Odoo 19 grants author-or-administrator editing through ThreadController._can_edit_message, so the route is stock again. Tests speak the Odoo 19 payload, are un-skipped, and assert a real NotFound denial so a controller crash can no longer pass as a denial. Stale translation entries for the deleted error string are dropped. Closes #419
gonzalesedwin1123
force-pushed
the
fix-419-mail-update-content
branch
from
September 17, 2026 02:44
8eb86f0 to
0d03634
Compare
Member
Author
Ready for review — CI green on
|
Review round on #522. The web client's Delete goes through the same route with removeParams, so it gets its own author/admin/bystander/ anonymous tests. Fixture users are now Registry Officers, the module's own persona with write on res.partner, instead of the generic Contact Creation group, so a regression in the module's ACL would surface here. The bystander tests assert the bystander may post on the thread, so the 404 can only come from the author gate. HISTORY now leads with the signature break and states the administrator-scope change. The unused logger in the controller module is dropped.
Member
Author
Ready for review — CI green on
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why is this change needed?
Fixes #419.
spp_registry/controllers/mail.pyoverrode/mail/message/update_content. The override came from the OpenG2Pg2p_registry_baseport (Odoo 17). It was already redundant there: stock 17 (mail/controllers/thread.py:121) granted author-or-administrator editing, and the override only narrowed "administrator" tobase.group_systemand answered with anAccessErrorinstead of a 404.On Odoo 19 the override never worked, and it is broken in three independent ways, not just the one the issue reports:
mail/static/src/core/common/message_model.js:581,:677) sends{message_id, update_data: {...}}, while the override's signature still required the Odoo 17 positionalbody/attachment_ids. Every real Edit or Delete of a chatter message — on any model, the route is global — failed withTypeErrorin the JSON-RPC envelope before the body ever ran. Message deletion in the UI goes through this same route (removeParams).ir.attachment._check_attachments_accessno longer exists (the issue's finding; replaced upstream by_has_attachments_ownership).mail.message.message_format()no longer exists either (Storereplaced it).So this is a user-visible production bug (edit/delete a chatter message → error toast), not only a test-suite wart.
Stock Odoo 19 already implements what the override carried:
ThreadController._can_edit_message(thread.py:263) isauthor OR res.users._is_admin(), andbase.group_systemimpliesbase.group_erp_manager. Upstream additionally requires the editor to be allowed to post on the thread (_get_message_with_access(mode="create"),_mail_post_access = "write"), which the override skipped.How was the change implemented?
SPPThreadControllerand the imports only it used, plus the pre-existing unusedlogging/loggerin the same import block (the onlyloggerrather than_loggerin the repo). The route is stock Odoo 19 again.SPPAttachmentController(/mail/attachment/delete) is untouched — see spp_registry: decide the fate of the /mail/attachment/delete override (policy differs from stock Odoo 19) and finish its two placeholder tests #523 for why it is not simply redundant.spp_registry19.0.2.2.4→19.0.2.2.5with areadme/HISTORY.mdentry that also states the access-scope change below.README.rst/static/description/index.htmlare applied verbatim from CI's pinnedoca-gen-addon-readmediff (docs commit).AccessErrorstring (spp_registry.pot,es.po,fr.po), same shape as the module's 19.0.2.1.4 cleanup; no new translatable strings.Behaviour change vs. the (never working on 19) override, stated in HISTORY: who may edit another user's message follows Odoo's own administrator test (superuser or
base.group_erp_manager"Administration: Access Rights", whichbase.group_systemimplies) instead ofgroup_systemonly — a strict superset; no OpenSPP role implies either group, so in practice the eligible set is unchanged. The editor must additionally be allowed to post on the record. Denials are a 404NotFoundrather than a 403-styleAccessError(better anti-enumeration).New unit tests
spp_registry/tests/test_mail_controllers.py::TestMailMessageUpdateContentControllerrewritten to the Odoo 19 payload, 8 tests, all running (previously 5 methods of which 3 wereskipTestplaceholders):update_data: {body, attachment_ids: []}):test_author_can_update_own_message,test_admin_can_update_any_message(un-skipped),test_bystander_cannot_update_anothers_message,test_unauthenticated_request_is_denied.update_data = Message.removeParams, exactly what the client sends):test_author_can_delete_own_message,test_admin_can_delete_any_message,test_bystander_cannot_delete_anothers_message,test_unauthenticated_delete_is_denied.error.code == 404anderror.data.name == "werkzeug.exceptions.NotFound"and that the body is unchanged, so a controller crash (TypeError/AttributeError) can never pass as a denial again — the failure mode spp_registry: /mail/message/update_content controller is broken on Odoo 19 — calls removed ir.attachment._check_attachments_access #419 exposed.NotFound, so the bystander tests first assert the bystander can post on the thread (has_access("write")), pinning that the 404 came from the author gate.spp_registry.group_registry_officer(the module's own persona with write onres.partner,security/ir.model.access.csv:28) rather than a generic base group, so a regression in the module's ACL would surface here. Stockgroup_useris read-only onres.partnerand cannot post on the thread.test_message_without_model_returns_not_found(an unimplementedskipTestTODO for a branch of the deleted override) removed. The two remaining skips are in the untouchedTestMailAttachmentDeleteControllerand are tracked in spp_registry: decide the fate of the /mail/attachment/delete override (policy differs from stock Odoo 19) and finish its two placeholder tests #523.Against the old controller the Edit tests fail RED with
TypeError: ... missing 2 required positional arguments: 'body' and 'attachment_ids'(reproducing break 1 live); against this branch all 8 are green.Unit tests executed by the author
Full
spp_registrysuite locally on the fix commit's code: 0 failed, 0 errors of 284 post-install tests (406 incl. at_install), 0 ERROR lines. Install-then--u spp_registryupgrade check on a fresh DB: clean,ir_module_module.latest_version = 19.0.2.2.5. CItest (spp_registry)re-runs the suite on every head.How to test manually
Prerequisites: two internal users — U1 (Registry Officer, or any internal user with Contacts write) and Admin (Settings access) — and a third internal user U2. Any record with a chatter works; a registrant form is used below.
19.0: log in as U1, open a registrant, Log note "hello", hover the note → ⋯ → Edit, change the text, Save → red error toast (TypeErrorin the RPC). Hover → ⋯ → Delete → same error.allowsEdition= admin OR self-authored). Calling the route directly returns a 404 envelope and the note is unchanged.Related links
/mail/attachment/deleteoverride enforces a different policy than stock 19 (author-or-group_systemvs write-on-attachment-or-token), so it needs a decision rather than a deletion; also tracks the two placeholder skips inTestMailAttachmentDeleteController.