mirror of
https://github.com/OCA/web.git
synced 2025-02-22 13:21:25 +02:00
[IMP] : simplify the code, use filtered function instead of a simple condition
This commit is contained in:
@@ -40,16 +40,15 @@ class web_shortcut(models.Model):
|
||||
def get_user_shortcuts(self, user_id):
|
||||
shortcuts = self.search([('user_id', '=', user_id)])
|
||||
res = []
|
||||
for shortcut in shortcuts:
|
||||
if shortcut.menu_id:
|
||||
_name = shortcut.menu_id.name_get()
|
||||
_name = _name[0][1] if len(_name) else ''
|
||||
_id = shortcut.menu_id.id
|
||||
res.append(
|
||||
{
|
||||
'id': shortcut.id,
|
||||
'name': _name,
|
||||
'menu_id': (_id, _name)
|
||||
}
|
||||
)
|
||||
for shortcut in shortcuts.filtered('menu_id'):
|
||||
_name = shortcut.menu_id.name_get()
|
||||
_name = _name[0][1] if len(_name) else ''
|
||||
_id = shortcut.menu_id.id
|
||||
res.append(
|
||||
{
|
||||
'id': shortcut.id,
|
||||
'name': _name,
|
||||
'menu_id': (_id, _name)
|
||||
}
|
||||
)
|
||||
return res
|
||||
|
||||
Reference in New Issue
Block a user