details:   https://code.tryton.org/tryton/commit/701d08639ed7
branch:    default
user:      Cédric Krier <[email protected]>
date:      Wed Feb 04 12:52:19 2026 +0100
description:
        Fill blank state of empty favorite menu

        Closes #14574
diffstat:

 sao/src/sao.js            |  63 +++++++++++++++++++++++++++++-----------------
 tryton/tryton/gui/main.py |  12 ++++++--
 2 files changed, 49 insertions(+), 26 deletions(-)

diffs (114 lines):

diff -r 6d9d821cc00f -r 701d08639ed7 sao/src/sao.js
--- a/sao/src/sao.js    Mon Feb 23 11:08:31 2026 +0100
+++ b/sao/src/sao.js    Wed Feb 04 12:52:19 2026 +0100
@@ -687,30 +687,38 @@
             });
             jQuery('#user-favorites').append(menu);
             Sao.rpc(args, session).then(function(fav) {
-                fav.forEach(function(menu_item) {
-                    var a = jQuery('<a/>', {
-                        'href': '#'
-                    });
-                    var id = menu_item[0];
-                    var li = jQuery('<li/>', {
-                        'role': 'presentation'
+                if (!fav.length) {
+                    jQuery('<li/>', {
+                        'class': 'dropdown-header',
+                        'role': 'presentation',
+                    }).text(Sao.i18n.gettext("Check menu entries to add 
favorites"))
+                    .appendTo(menu);
+                } else {
+                    fav.forEach(function(menu_item) {
+                        var a = jQuery('<a/>', {
+                            'href': '#'
+                        });
+                        var id = menu_item[0];
+                        var li = jQuery('<li/>', {
+                            'role': 'presentation'
+                        });
+                        var icon = Sao.common.ICONFACTORY.get_icon_img(
+                            menu_item[2], {'class': 'favorite-icon'});
+                        a.append(icon);
+                        li.append(a);
+                        a.append(menu_item[1]);
+                        a.click(function(evt) {
+                            evt.preventDefault();
+                            Sao.favorites_menu_clear();
+                            // ids is not defined to prevent to add suffix
+                            Sao.Action.exec_keyword('tree_open', {
+                                'model': Sao.main_menu_screen.model_name,
+                                'id': id,
+                            });
+                        });
+                        menu.append(li);
                     });
-                    var icon = Sao.common.ICONFACTORY.get_icon_img(
-                        menu_item[2], {'class': 'favorite-icon'});
-                    a.append(icon);
-                    li.append(a);
-                    a.append(menu_item[1]);
-                    a.click(function(evt) {
-                        evt.preventDefault();
-                        Sao.favorites_menu_clear();
-                        // ids is not defined to prevent to add suffix
-                        Sao.Action.exec_keyword('tree_open', {
-                            'model': Sao.main_menu_screen.model_name,
-                            'id': id,
-                        });
-                    });
-                    menu.append(li);
-                });
+                }
             });
         }
     };
@@ -857,6 +865,11 @@
                     var icon = 'tryton-star';
                     if (!record._values.favorite) {
                         icon += '-border';
+                        cell.attr('title', Sao.i18n.gettext(
+                            "Add to favorites"));
+                    } else {
+                        cell.attr('title', Sao.i18n.gettext(
+                            "Remove from favorites"));
                     }
                     cell.data('star', Boolean(record._values.favorite));
                     Sao.common.ICONFACTORY.get_icon_url(icon)
@@ -886,9 +899,13 @@
             if (!star) {
                 icon = 'tryton-star';
                 method = 'set';
+                button.attr('title', Sao.i18n.gettext(
+                    "Remove from favorites"));
             } else {
                 icon = 'tryton-star-border';
                 method = 'unset';
+                button.attr('title', Sao.i18n.gettext(
+                    "Add to favorites"));
             }
             button.data('star', !star);
             Sao.common.ICONFACTORY.get_icon_url(icon)
diff -r 6d9d821cc00f -r 701d08639ed7 tryton/tryton/gui/main.py
--- a/tryton/tryton/gui/main.py Mon Feb 23 11:08:31 2026 +0100
+++ b/tryton/tryton/gui/main.py Wed Feb 04 12:52:19 2026 +0100
@@ -477,10 +477,16 @@
                 process_exception=False)
         except RPCException:
             return False
-        for id_, name, icon in favorites:
-            menuitem = Gtk.MenuItem(label=name)
-            menuitem.connect('activate', _action_favorite, id_)
+        if not favorites:
+            menuitem = Gtk.MenuItem(
+                label=_("Check menu entries to add favorites"))
+            menuitem.set_sensitive(False)
             self.menu_favorite.add(menuitem)
+        else:
+            for id_, name, icon in favorites:
+                menuitem = Gtk.MenuItem(label=name)
+                menuitem.connect('activate', _action_favorite, id_)
+                self.menu_favorite.add(menuitem)
         self.menu_favorite.show_all()
 
     def favorite_unset(self):

Reply via email to