From 72aa28e6c4d320a85f969eb6d648c7c0302975c0 Mon Sep 17 00:00:00 2001 From: gsinghpal Date: Tue, 26 May 2026 21:20:08 -0400 Subject: [PATCH] feat(fusion_login_audit): smart button + Login Activity tab on res.users MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Adds four x_fc_* fields on res.users: login_audit_ids (One2many), login_audit_count (compute), last_successful_login (compute, stored), last_login_ip (compute, stored). action_fc_view_login_audit returns a window action scoped to the current user. View inheritance adds a smart button to the button box and a "Login Activity" page to the notebook, both gated by base.group_system on the inner XML nodes (NOT on the view record — Odoo 19 forbids that; see CLAUDE.md rule #11). Tests (2 new, 18 total green): test_computed_last_successful_login — uses registry cursor to commit the audit row so the stored compute picks it up across the TransactionCase boundary. test_action_view_login_audit_returns_window_action — smart-button action shape + domain scoping. CLAUDE.md rule #11 added: inherited ir.ui.view records cannot have groups/group_ids on the record; the gate must be on the inner XML nodes. Co-Authored-By: Claude Opus 4.7 (1M context) --- CLAUDE.md | 2 + fusion_login_audit/__manifest__.py | 1 + fusion_login_audit/models/res_users.py | 65 +++++++++++++++++++- fusion_login_audit/tests/test_login_audit.py | 39 ++++++++++++ fusion_login_audit/views/res_users_views.xml | 56 +++++++++++++++++ 5 files changed, 162 insertions(+), 1 deletion(-) create mode 100644 fusion_login_audit/views/res_users_views.xml diff --git a/CLAUDE.md b/CLAUDE.md index f5fce209..6f5c331a 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -14,6 +14,7 @@ 5. **res.config.settings**: Only boolean/integer/float/char/selection/many2one/datetime. NO Date fields. 6. **res.groups**: NO `users` field, NO `category_id` field. **res.users**: field was renamed `groups_id` → `group_ids` (also `all_group_ids` for implied). The plural form is gone; using `groups_id` raises `ValueError: Invalid field 'groups_id' in 'res.users'`. + **`ir.ui.view`**: same rename — view-level visibility gating uses `group_ids`, not `groups_id`. A record like `` on an `ir.ui.view` raises `ValueError: Invalid field 'groups_id' in 'ir.ui.view'` at module install. (The XML *attribute* `groups="base.group_system"` on form elements like ``, ` + + + + + + + + + + + + + + + + + + + + + + + + + + +