diff --git a/addons/web/static/src/js/chrome/user_menu.js b/addons/web/static/src/js/chrome/user_menu.js index f617eb1e..8452590d 100644 --- a/addons/web/static/src/js/chrome/user_menu.js +++ b/addons/web/static/src/js/chrome/user_menu.js @@ -161,30 +161,32 @@ var UserProfile = Widget.extend({ method: 'search_read', args: [[["code", "=", session.user_context.lang]], ['name', 'direction']], }).then(function(lang_data){ - var img_src = session.url('/web/image', { - model:'res.lang', - field: 'image', - id: lang_data[0].id, - }); - $lang_logo.attr('title', lang_data[0].name).attr('src', img_src).attr('data-lang-dir', lang_data[0].direction); + if (lang_data.length) { + var img_src = session.url('/web/image', { + model: 'res.lang', + field: 'image', + id: lang_data[0].id, + }); + $lang_logo.attr('title', lang_data[0].name).attr('src', img_src).attr('data-lang-dir', lang_data[0].direction); - // Web RTL(Right to Left) Snippet - if (lang_data[0].direction == 'rtl') { - var head = document.getElementsByTagName('head')[0]; + // Web RTL(Right to Left) Snippet + if (lang_data[0].direction == 'rtl') { + var head = document.getElementsByTagName('head')[0]; - // BootStrap RTL CSS - var link = document.createElement('link'); - link.rel = 'stylesheet'; - link.type = 'text/css'; - link.href = '/web/static/lib/rtl/bootstrap-rtl.min.css'; - head.appendChild(link); + // BootStrap RTL CSS + var link = document.createElement('link'); + link.rel = 'stylesheet'; + link.type = 'text/css'; + link.href = '/web/static/lib/rtl/bootstrap-rtl.min.css'; + head.appendChild(link); - // Flectra RTL Custom CSS - var link1 = document.createElement('link'); - link1.rel = 'stylesheet'; - link1.type = 'text/css'; - link1.href = '/web/static/lib/rtl/flectra-rtl-custom.css'; - head.appendChild(link1); + // Flectra RTL Custom CSS + var link1 = document.createElement('link'); + link1.rel = 'stylesheet'; + link1.type = 'text/css'; + link1.href = '/web/static/lib/rtl/flectra-rtl-custom.css'; + head.appendChild(link1); + } } }); $avatar.attr('src', avatar_src);