Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions tryton/tryton/gui/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,10 @@ def on_change_action_boolean(action, value, key):
self.add_action(action)
self.set_accels_for_action('app.shortcuts', ['<Primary>F1'])

action = Gio.SimpleAction.new('logout', None)
action.connect('activate', self.logout)
self.add_action(action)

action = Gio.SimpleAction.new('about', None)
action.connect('activate', lambda *a: self.about())
self.add_action(action)
Expand Down Expand Up @@ -298,6 +302,7 @@ def add_window(self, window):
def _get_primary_menu(self):
menu = Gio.Menu.new()
menu.append(_("Preferences..."), 'app.preferences')
menu.append(_("Log out"), 'app.logout')

section = Gio.Menu.new()
toolbar = Gio.Menu.new()
Expand Down Expand Up @@ -658,6 +663,7 @@ def shortcuts(self):
('app.tab-previous', _("Previous tab"), ),
('app.tab-next', _("Next tab")),
('app.shortcuts', _("Shortcuts")),
('app.logout', _("Log out")),
('app.quit', _("Quit")),
]:
shortcut = Gtk.ShortcutsShortcut()
Expand Down Expand Up @@ -1115,3 +1121,24 @@ def show_notification(self, title, msg, priority=1):
notification.set_priority(_PRIORITIES[priority])
if sys.platform != 'win32' or GLib.glib_version >= (2, 57, 0):
self.send_notification(None, notification)

def logout(self, *args):
from tryton.gui.window.dblogin import DBLogin

try:
if not self.close_pages():
return True
except TrytonServerUnavailable:
pass
self.menu_screen = None
self.window.hide()
rpc.logout()

if DBLogin().run():
try:
common.get_credentials()
except Exception:
return self.quit()
self.get_preferences()
else:
self.quit()
4 changes: 4 additions & 0 deletions tryton/tryton/rpc.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,10 @@ def logout():
CONNECTION = None
_CLIENT_DATE = None
_USER = None
_VIEW_CACHE.clear()
_TOOLBAR_CACHE.clear()
_KEYWORD_CACHE.clear()
CONTEXT.clear()


def execute(*args):
Expand Down