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

@@ -62,7 +62,7 @@ The user can get the help document just by one click.
'depends': ['base', 'web', 'mail'], 'depends': ['base', 'web', 'mail'],
'data': [ 'data': [
'views/app_odoo_customize_view.xml', 'views/app_odoo_customize_view.xml',
'views/app_theme_config_settings_view.xml', # 'views/app_theme_config_settings_view.xml',
'views/ir_model_view.xml', 'views/ir_model_view.xml',
# data # data
'data/ir_config_parameter.xml', 'data/ir_config_parameter.xml',

View File

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

View File

@@ -1,21 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<templates xml:space="preserve"> <templates xml:space="preserve">
<t t-extend="UserMenu"> <t t-extend="UserMenu.Actions">
<t t-jquery=".dropdown-menu" t-operation="prepend"> <t t-jquery="a[data-menu='documentation']" t-operation="before">
<switch-lang/> <switch-lang/>
<li> <a role="menuitem" href="#" data-menu="debug" class="dropdown-item">Activate the developer mode</a>
<a href="#" data-menu="debug">Activate the developer mode</a> <a role="menuitem" href="#" data-menu="debugassets" class="dropdown-item">Activate the developer mode (with assets)</a>
</li> <a role="menuitem" href="#" data-menu="quitdebug" class="dropdown-item">Deactivate the developer mode</a>
<li> <div role="separator" class="dropdown-divider"/>
<a href="#" data-menu="debugassets">Activate the developer mode (with assets)</a> <a role="menuitem" href="#" data-menu="documentation_dev" class="dropdown-item">Developer Manual</a>
</li>
<li>
<a href="#" data-menu="quitdebug">Deactivate the developer mode</a>
</li>
<li>
<a href="#" data-menu="documentation_dev">Developer Manual</a>
</li>
<li class="divider"/>
</t> </t>
</t> </t>
</templates> </templates>