Browse Source

Merge pull request #694 from maxodoo/translated_shortcut_menu

translate shortcut menu items to user's language
pull/730/head
Pedro M. Baeza 7 years ago
committed by GitHub
parent
commit
ff7c7649ba
  1. 7
      web_shortcut/README.rst
  2. 15
      web_shortcut/models/web_shortcut.py

7
web_shortcut/README.rst

@ -28,6 +28,12 @@ To use this module, you need to:
:alt: Try me on Runbot
:target: https://runbot.odoo-community.org/runbot/162/10.0
Known Issues
============
Clicking shortcut menu item sometimes doesn't trigger the left side submenu widget
updating except reloading the whole page.
Client side may raise TypeError exception randomly: this.active_view is null.
Bug Tracker
===========
@ -46,6 +52,7 @@ Contributors
* Dennis Sluijk <d.sluijk@onestein.nl>
* Odoo SA
* Thomas Binsfeld <thomas.binsfeld@acsone.eu>
* Henry Zhou (MAXodoo) <zhouhenry@live.com>
Maintainer
----------

15
web_shortcut/models/web_shortcut.py

@ -23,14 +23,27 @@ 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