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, {
|
||||
setup() {
|
||||
super.setup();
|
||||
|
||||
"use strict";
|
||||
// this.companyService = useService("company");
|
||||
this.orm = useService("orm");
|
||||
this.app_show_lang = session.app_show_lang;
|
||||
this.app_lang_list = session.app_lang_list;
|
||||
// self.companyService = useService("company");
|
||||
let self = this;
|
||||
self.orm = useService("orm");
|
||||
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 写了展现
|
||||
|
||||
//修正 bug,在移动端不会关闭本身
|
||||
@@ -31,11 +32,11 @@ patch(UserMenu.prototype, {
|
||||
description: _t("Preferences"),
|
||||
callback: async function () {
|
||||
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 {
|
||||
let m = document.getElementsByClassName("o_burger_menu_close");
|
||||
let m = document.getElementsByClassName("o_sidebar_close");
|
||||
if (m) {
|
||||
m[0].click();
|
||||
m[0].click({ root: document.body });
|
||||
}
|
||||
} catch (e) {
|
||||
;
|
||||
@@ -46,17 +47,18 @@ patch(UserMenu.prototype, {
|
||||
sequence: 50,
|
||||
};
|
||||
}
|
||||
|
||||
userMenuRegistry.add("profile", preferencesItem, {'force': true, 'menu': this});
|
||||
userMenuRegistry.add("refresh_current", refresh_current, {'force': true});
|
||||
|
||||
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) {
|
||||
userMenuRegistry.add("debug", debugItem, {'force': true})
|
||||
.add("asset_asset", activateAssetsDebugging, {'force': true})
|
||||
.add("leave_debug", leaveDebugMode, {'force': true})
|
||||
.add("separator10", separator10, {'force': true})
|
||||
.add("separator10", separator10, {'force': true});
|
||||
}
|
||||
if (session.app_show_documentation) {
|
||||
userMenuRegistry.add("documentation", documentationItem, {'force': true});
|
||||
@@ -88,14 +90,15 @@ patch(UserMenu.prototype, {
|
||||
async setLang(lang_code) {
|
||||
"use strict";
|
||||
// alert(lang_code);
|
||||
browser.clearTimeout(this.toggleTimer);
|
||||
if (this.user.lang !== lang_code) {
|
||||
const res = await this.orm.call("res.users", "write", [
|
||||
let self = this;
|
||||
browser.clearTimeout(self.toggleTimer);
|
||||
if (self.user_lang !== lang_code) {
|
||||
const res = await self.orm.call("res.users", "write", [
|
||||
session.uid, {'lang': lang_code}
|
||||
]);
|
||||
location.reload();
|
||||
// 调用 action , 要先定义 this.action = useService("action")
|
||||
// this.action.action({
|
||||
// 调用 action , 要先定义 self.action = useService("action")
|
||||
// self.action.action({
|
||||
// type: 'ir.actions.client',
|
||||
// tag: 'reload_context',
|
||||
// });
|
||||
@@ -112,6 +115,7 @@ function debugItem(env) {
|
||||
callback: () => {
|
||||
router.pushState({ debug: 1 }, { reload: true });
|
||||
},
|
||||
show: () => !env.debug || !env.debug.includes("assets"),
|
||||
sequence: 5,
|
||||
};
|
||||
}
|
||||
@@ -124,6 +128,7 @@ function activateAssetsDebugging(env) {
|
||||
callback: () => {
|
||||
router.pushState({ debug: 'assets' }, { reload: true });
|
||||
},
|
||||
show: () => !env.debug.includes("assets"),
|
||||
sequence: 6,
|
||||
};
|
||||
}
|
||||
@@ -136,6 +141,7 @@ function leaveDebugMode(env) {
|
||||
callback: () => {
|
||||
router.pushState({ debug: 0 }, { reload: true });
|
||||
},
|
||||
show: () => env.debug,
|
||||
sequence: 7,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
.o_user_menu .dropdown-menu img,
|
||||
.o_user_menu_mobile .dropdown-item img {
|
||||
.o-overlay-container .dropdown-menu img.flag,
|
||||
.o_user_menu_mobile .dropdown-item img.flag {
|
||||
height: 20px;
|
||||
margin: 2px;
|
||||
}
|
||||
|
||||
@@ -4,10 +4,11 @@
|
||||
<xpath expr="//t[@t-key='element_index']" position="before">
|
||||
<t t-if="app_show_lang">
|
||||
<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'"/>
|
||||
<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>
|
||||
</t>
|
||||
</t>
|
||||
|
||||
Reference in New Issue
Block a user