Skip to content

Warn user and prevent switching when no remote account is logged in - #338

Merged
suraj-yadav0 merged 5 commits into
CITOpenRep:release/v1.3.3from
AnmollGarg:fix/account-switch-validation
Sep 14, 2026
Merged

suraj-yadav0 merged 5 commits into
CITOpenRep:release/v1.3.3from
AnmollGarg:fix/account-switch-validation

Conversation

@AnmollGarg

Copy link
Copy Markdown
Contributor

Summary

Prevents toggling the local account switch when no remote account is logged in, keeps the switch UI in sync, and displays a warning notification dialog to the user.

Type

  • Bug Fix
  • Refactor

Motivation

Previously, when a user had only the default Local Account (id: 0) and attempted to flip the local toggle switch off, toggleLocalMode() in AccountSelectorDialog.qml fell back to calling open(selectedAccountId). This inappropriately popped open the account selection dialog instead of notifying the user. Furthermore, because no account was actually switched, none of the account change signals were fired, leaving the switch visually in the OFF state while the app remained on the Local Account.

Changes

  1. Added hasRemoteAccount() in models/accounts.js: Queries SQLite users table to determine whether any remote user account (id > 0) exists.
  2. Updated toggleLocalMode() in AccountSelectorDialog.qml:
    • Validates that lastRemoteAccountId still exists in the database.
    • Triggers notifPopup.open() warning ("You don't have any account logged in") and returns false when no remote account exists (targetId <= 0), replacing the previous open() fallback.
  3. Guarded Switch UI in MenuPage.qml & AppDrawer.qml:
    • Checks the return value of accountPicker.toggleLocalMode(checked).
    • Reverts checked = true immediately if toggling fails, preventing switch desynchronization.

Testing

  • Tested on Emulator (clickable build && clickable review)
  • Tested on device (clickable install)
  • No existing Functionality/Tests broken

Checklist

  • Code follows existing style conventions
  • No hardcoded credentials or secrets
  • No debug logs left in production code
  • PR is up-to-date with release/v1.3.3 branch

Related Issues

#334

Additional Notes

Applied consistently across both the desktop/tablet sidebar (MenuPage.qml) and the mobile drawer (AppDrawer.qml).

@suraj-yadav0 suraj-yadav0 self-assigned this Sep 9, 2026
@suraj-yadav0 suraj-yadav0 added the enhancement New feature or request label Sep 9, 2026

@suraj-yadav0 suraj-yadav0 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just Remove the Unused function and its wrapper , and we are good to go..!!

Comment thread models/accounts.js
@AnmollGarg
AnmollGarg force-pushed the fix/account-switch-validation branch from 8382a60 to 3f84b84 Compare September 9, 2026 12:46
…nt-switch-validation

# Conflicts:
#	qml/app/AppDrawer.qml
#	qml/app/navigation/MenuPage.qml
…ep#334)

- Make NotificationPopup modal and guard open() with activeDialog reference
- Guard AccountSelectorDialog open() against duplicate active dialogs
- Reset activeDialog on dialog destruction and close

@suraj-yadav0 suraj-yadav0 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@suraj-yadav0
suraj-yadav0 merged commit 13b5204 into CITOpenRep:release/v1.3.3 Sep 14, 2026
1 check passed
@suraj-yadav0 suraj-yadav0 mentioned this pull request Sep 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Multiple pop-ups open when repeatedly clicking account toggle without an Odoo account

2 participants