mirror of
https://github.com/guohuadeng/app-odoo.git
synced 2025-02-23 04:11:36 +02:00
fix update odoo 18
This commit is contained in:
@@ -14,12 +14,13 @@ const userMenuRegistry = registry.category("user_menuitems");
|
|||||||
patch(UserMenu.prototype, {
|
patch(UserMenu.prototype, {
|
||||||
setup() {
|
setup() {
|
||||||
super.setup();
|
super.setup();
|
||||||
|
|
||||||
"use strict";
|
"use strict";
|
||||||
// this.companyService = useService("company");
|
// self.companyService = useService("company");
|
||||||
this.orm = useService("orm");
|
let self = this;
|
||||||
this.app_show_lang = session.app_show_lang;
|
self.orm = useService("orm");
|
||||||
this.app_lang_list = session.app_lang_list;
|
self.app_show_lang = session.app_show_lang;
|
||||||
|
self.app_lang_list = session.app_lang_list;
|
||||||
|
self.user_lang = session.bundle_params.lang;
|
||||||
//todo: 演习 shortCutsItem 中的用法,当前是直接 xml 写了展现
|
//todo: 演习 shortCutsItem 中的用法,当前是直接 xml 写了展现
|
||||||
|
|
||||||
//修正 bug,在移动端不会关闭本身
|
//修正 bug,在移动端不会关闭本身
|
||||||
@@ -31,11 +32,11 @@ patch(UserMenu.prototype, {
|
|||||||
description: _t("Preferences"),
|
description: _t("Preferences"),
|
||||||
callback: async function () {
|
callback: async function () {
|
||||||
const actionDescription = await env.services.orm.call("res.users", "action_get");
|
const actionDescription = await env.services.orm.call("res.users", "action_get");
|
||||||
actionDescription.res_id = env.services.user.userId;
|
actionDescription.res_id = session.user_id[0];
|
||||||
try {
|
try {
|
||||||
let m = document.getElementsByClassName("o_burger_menu_close");
|
let m = document.getElementsByClassName("o_sidebar_close");
|
||||||
if (m) {
|
if (m) {
|
||||||
m[0].click();
|
m[0].click({ root: document.body });
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
;
|
;
|
||||||
@@ -46,17 +47,18 @@ patch(UserMenu.prototype, {
|
|||||||
sequence: 50,
|
sequence: 50,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
userMenuRegistry.add("profile", preferencesItem, {'force': true, 'menu': this});
|
userMenuRegistry.add("profile", preferencesItem, {'force': true, 'menu': this});
|
||||||
userMenuRegistry.add("refresh_current", refresh_current, {'force': true});
|
userMenuRegistry.add("refresh_current", refresh_current, {'force': true});
|
||||||
|
|
||||||
if (session.app_show_lang) {
|
if (session.app_show_lang) {
|
||||||
userMenuRegistry.add("separator1", separator1, {'force': true})
|
userMenuRegistry.add("separator1", separator1, {'force': true});
|
||||||
}
|
}
|
||||||
if (session.app_show_debug && session.is_erp_manager) {
|
if (session.app_show_debug && session.is_erp_manager) {
|
||||||
userMenuRegistry.add("debug", debugItem, {'force': true})
|
userMenuRegistry.add("debug", debugItem, {'force': true})
|
||||||
.add("asset_asset", activateAssetsDebugging, {'force': true})
|
.add("asset_asset", activateAssetsDebugging, {'force': true})
|
||||||
.add("leave_debug", leaveDebugMode, {'force': true})
|
.add("leave_debug", leaveDebugMode, {'force': true})
|
||||||
.add("separator10", separator10, {'force': true})
|
.add("separator10", separator10, {'force': true});
|
||||||
}
|
}
|
||||||
if (session.app_show_documentation) {
|
if (session.app_show_documentation) {
|
||||||
userMenuRegistry.add("documentation", documentationItem, {'force': true});
|
userMenuRegistry.add("documentation", documentationItem, {'force': true});
|
||||||
@@ -88,14 +90,15 @@ patch(UserMenu.prototype, {
|
|||||||
async setLang(lang_code) {
|
async setLang(lang_code) {
|
||||||
"use strict";
|
"use strict";
|
||||||
// alert(lang_code);
|
// alert(lang_code);
|
||||||
browser.clearTimeout(this.toggleTimer);
|
let self = this;
|
||||||
if (this.user.lang !== lang_code) {
|
browser.clearTimeout(self.toggleTimer);
|
||||||
const res = await this.orm.call("res.users", "write", [
|
if (self.user_lang !== lang_code) {
|
||||||
|
const res = await self.orm.call("res.users", "write", [
|
||||||
session.uid, {'lang': lang_code}
|
session.uid, {'lang': lang_code}
|
||||||
]);
|
]);
|
||||||
location.reload();
|
location.reload();
|
||||||
// 调用 action , 要先定义 this.action = useService("action")
|
// 调用 action , 要先定义 self.action = useService("action")
|
||||||
// this.action.action({
|
// self.action.action({
|
||||||
// type: 'ir.actions.client',
|
// type: 'ir.actions.client',
|
||||||
// tag: 'reload_context',
|
// tag: 'reload_context',
|
||||||
// });
|
// });
|
||||||
@@ -112,6 +115,7 @@ function debugItem(env) {
|
|||||||
callback: () => {
|
callback: () => {
|
||||||
router.pushState({ debug: 1 }, { reload: true });
|
router.pushState({ debug: 1 }, { reload: true });
|
||||||
},
|
},
|
||||||
|
show: () => !env.debug || !env.debug.includes("assets"),
|
||||||
sequence: 5,
|
sequence: 5,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@@ -124,6 +128,7 @@ function activateAssetsDebugging(env) {
|
|||||||
callback: () => {
|
callback: () => {
|
||||||
router.pushState({ debug: 'assets' }, { reload: true });
|
router.pushState({ debug: 'assets' }, { reload: true });
|
||||||
},
|
},
|
||||||
|
show: () => !env.debug.includes("assets"),
|
||||||
sequence: 6,
|
sequence: 6,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@@ -136,6 +141,7 @@ function leaveDebugMode(env) {
|
|||||||
callback: () => {
|
callback: () => {
|
||||||
router.pushState({ debug: 0 }, { reload: true });
|
router.pushState({ debug: 0 }, { reload: true });
|
||||||
},
|
},
|
||||||
|
show: () => env.debug,
|
||||||
sequence: 7,
|
sequence: 7,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
.o_user_menu .dropdown-menu img,
|
.o-overlay-container .dropdown-menu img.flag,
|
||||||
.o_user_menu_mobile .dropdown-item img {
|
.o_user_menu_mobile .dropdown-item img.flag {
|
||||||
height: 20px;
|
height: 20px;
|
||||||
margin: 2px;
|
margin: 2px;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,10 +4,11 @@
|
|||||||
<xpath expr="//t[@t-key='element_index']" position="before">
|
<xpath expr="//t[@t-key='element_index']" position="before">
|
||||||
<t t-if="app_show_lang">
|
<t t-if="app_show_lang">
|
||||||
<t t-foreach="app_lang_list" t-as="lang" t-key="lang.id">
|
<t t-foreach="app_lang_list" t-as="lang" t-key="lang.id">
|
||||||
<DropdownItem dataset="{ lang: lang.id, code: lang.code }" onSelected="() => this.setLang(lang.code)">
|
<DropdownItem attrs="{ 'data-lang': lang.id, 'data-code': lang.code }"
|
||||||
|
onSelected="() => this.setLang(lang.code)">
|
||||||
<img class="flag" t-att-src="'/app_odoo_customize/static/src/img/flags/' + lang['code'] + '.png'"/>
|
<img class="flag" t-att-src="'/app_odoo_customize/static/src/img/flags/' + lang['code'] + '.png'"/>
|
||||||
<t t-out="lang.name"/>
|
<t t-out="lang.name"/>
|
||||||
<i class="fa fa-check" t-if="user.lang == lang.code"></i>
|
<i class="fa fa-check" t-if="user_lang == lang.code"></i>
|
||||||
</DropdownItem>
|
</DropdownItem>
|
||||||
</t>
|
</t>
|
||||||
</t>
|
</t>
|
||||||
|
|||||||
Reference in New Issue
Block a user