v1 update odoo_customize

This commit is contained in:
ivan deng
2018-09-19 20:50:08 +08:00
parent 17963fab85
commit 532fb017ed
3 changed files with 66 additions and 73 deletions

View File

@@ -12,10 +12,10 @@ odoo.define('app_odoo_customize.UserMenu', function (require) {
var UserMenu = require('web.UserMenu');
//避免错误,要再定义
var documentation_url = 'http://www.sunpop.cn';
var documentation_dev_url;
var support_url;
var account_title;
var account_url;
var documentation_dev_url = 'http://www.sunpop.cn';
var support_url = 'http://www.sunpop.cn';
var account_title = 'My Account';
var account_url = 'http://www.sunpop.cn';
UserMenu.include({
init: function () {
@@ -38,60 +38,61 @@ odoo.define('app_odoo_customize.UserMenu', function (require) {
} else {
a = '';
}
lang_list += '<li><a href="#" data-lang-menu="lang" data-lang-id="' + lang['code'] + '"><img class="flag" src="app_odoo_customize/static/src/img/flags/' + lang['code'] + '.png"/>' + lang['name'] + a + '</a></li>';
lang_list += '<a role="menuitem" href="#" class="dropdown-item" data-lang-menu="lang" data-lang-id="' + lang['code']
+ '"><img class="flag" src="app_odoo_customize/static/src/img/flags/' + lang['code'] + '.png"/>' + lang['name'] + a + '</a>';
});
lang_list += '<li class="divider"></li>';
lang_list += '<div role="separator" class="dropdown-divider"/>';
$('switch-lang').replaceWith(lang_list);
})
//取参数
self._rpc({
model: 'ir.config_parameter',
method: 'search_read',
domain: [['key', '=like', 'app_%']],
fields: ['key', 'value'],
lazy: false,
}).then(function (res) {
$.each(res, function (key, val) {
if (val.key == 'app_documentation_url')
documentation_url = val.value;
if (val.key == 'app_documentation_dev_url')
documentation_dev_url = val.value;
if (val.key == 'app_support_url')
support_url = val.value;
if (val.key == 'app_account_title')
account_title = val.value;
if (val.key == 'app_account_url')
account_url = val.value;
// 控制显示
if (val.key == 'app_show_lang' && val.value == "False") {
$('switch-lang').hide();
}
if (session.user_context.uid!=1 || (val.key == 'app_show_debug' && val.value == "False")) {
$('[data-menu="debug"]').parent().hide();
$('[data-menu="debugassets"]').parent().hide();
$('[data-menu="quitdebug"]').parent().hide();
}
if (val.key == 'app_show_documentation' && val.value == "False") {
$('[data-menu="documentation"]').parent().hide();
}
if (val.key == 'app_show_documentation_dev' && val.value == "False") {
$('[data-menu="documentation_dev"]').parent().hide();
}
if (val.key == 'app_show_support' && val.value == "False") {
$('[data-menu="support"]').parent().hide();
}
if (val.key == 'app_show_account' && val.value == "False") {
$('[data-menu="account"]').parent().hide();
}
if (val.key == 'app_account_title' && val.value) {
$('[data-menu="account"]').html(account_title);
}
if (val.key == 'app_show_poweredby' && val.value == "False") {
$('.o_sub_menu_footer').hide();
}
});
})
// self._rpc({
// model: 'ir.config_parameter',
// method: 'search_read',
// domain: [['key', '=like', 'app_%']],
// fields: ['key', 'value'],
// lazy: false,
// }).then(function (res) {
// $.each(res, function (key, val) {
// if (val.key == 'app_documentation_url')
// documentation_url = val.value;
// if (val.key == 'app_documentation_dev_url')
// documentation_dev_url = val.value;
// if (val.key == 'app_support_url')
// support_url = val.value;
// if (val.key == 'app_account_title')
// account_title = val.value;
// if (val.key == 'app_account_url')
// account_url = val.value;
// // 控制显示
// if (val.key == 'app_show_lang' && val.value == "False") {
// $('switch-lang').hide();
// }
// if (session.user_context.uid!=1 || (val.key == 'app_show_debug' && val.value == "False")) {
// $('[data-menu="debug"]').parent().hide();
// $('[data-menu="debugassets"]').parent().hide();
// $('[data-menu="quitdebug"]').parent().hide();
// }
// if (val.key == 'app_show_documentation' && val.value == "False") {
// $('[data-menu="documentation"]').parent().hide();
// }
// if (val.key == 'app_show_documentation_dev' && val.value == "False") {
// $('[data-menu="documentation_dev"]').parent().hide();
// }
// if (val.key == 'app_show_support' && val.value == "False") {
// $('[data-menu="support"]').parent().hide();
// }
// if (val.key == 'app_show_account' && val.value == "False") {
// $('[data-menu="account"]').parent().hide();
// }
// if (val.key == 'app_account_title' && val.value) {
// $('[data-menu="account"]').html(account_title);
// }
// if (val.key == 'app_show_poweredby' && val.value == "False") {
// $('.o_sub_menu_footer').hide();
// }
// });
// })
},
/**
* @override
@@ -101,7 +102,7 @@ odoo.define('app_odoo_customize.UserMenu', function (require) {
var self = this;
return this._super.apply(this, arguments).then(function () {
//语言切换特殊处理
self.$el.on('click', 'li a[data-lang-menu]', function (ev) {
self.$el.on('click', 'a[data-lang-menu]', function (ev) {
ev.preventDefault();
var f = self['_onMenuLang']
f.call(self, $(this));
@@ -113,11 +114,11 @@ odoo.define('app_odoo_customize.UserMenu', function (require) {
if (window.location.href.indexOf('debug=assets') != -1)
mMode = 'assets';
if (mMode == 'normal')
$('[data-menu="quitdebug"]').parent().hide();
$('[data-menu="quitdebug"]').hide();
if (mMode == 'debug')
$('[data-menu="debug"]').parent().hide();
$('[data-menu="debug"]').hide();
if (mMode == 'assets')
$('[data-menu="debugassets"]').parent().hide();
$('[data-menu="debugassets"]').hide();
});
},
_onMenuAccount: function () {