Browse Source

translate shortcut menu items to user's language

pull/694/head
jlzhou 7 years ago
parent
commit
a713dc1646
  1. 1
      web_shortcut/README.rst
  2. 10
      web_shortcut/models/web_shortcut.py

1
web_shortcut/README.rst

@ -42,6 +42,7 @@ Credits
Contributors
------------
* Henry Zhou (MAXodoo) <zhouhenry@live.com>
* Adrien Peiffer
* Dennis Sluijk <d.sluijk@onestein.nl>
* Odoo SA

10
web_shortcut/models/web_shortcut.py

@ -23,14 +23,22 @@ class WebShortcut(models.Model):
def get_user_shortcuts(self):
shortcuts = self.search([('user_id', '=', self.env.user.id)])
res = []
trans = self.env['ir.translation']
for shortcut in shortcuts.filtered('menu_id'):
name_translated = trans._get_source('ir.ui.menu,name', 'model', self.env.user.lang, shortcut.menu_id.name,
shortcut.menu_id.id)
current = shortcut.menu_id
while current.parent_id:
current = current.parent_id
name_translated = ' / '.join((trans._get_source('ir.ui.menu,name', 'model', self.env.user.lang,
current.name, current.id), name_translated))
_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,
'name': name_translated,
'menu_id': (_id, _name)
}
)

Loading…
Cancel
Save