标题使用标准 html 设置<title
tag in /addons/web/views/webclient_templates.xml,在web.layout模板:
<template id="web.layout" name="Web layout"><!DOCTYPE html>
<html style="height: 100%">
<head>
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"/>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>Odoo</title>
<link rel="shortcut icon" href="/web/static/src/img/favicon.ico" type="image/x-icon"/>
<link rel="stylesheet" href="/web/static/src/css/full.css" />
<t t-raw="head or ''"/>
</head>
<body t-att-class="body_classname">
<t t-raw="0"/>
</body>
</html>
</template>
因此,您可以在自定义模块的 xml 文件中更改它,如下所示:
<?xml version="1.0" encoding="UTF-8"?>
<openerp>
<data>
<template id="custom_title" name="change title" inherit_id="web.layout">
<xpath expr="//title" position="replace">
<title>Your title</title>
</xpath>
</template>
</data>
</openerp>
请务必在清单文件中声明 xml 文件并重新加载模块。
这适用于登录页面(如果所选数据库安装了包含此更改的模块),但它不适用于大多数其他页面,因为加载视图时标题会由 javascript 客户端动态更改。 (反映您所在的视图,例如“产品 - Odoo”
或“客户 - Odoo”)
要改变这一点,您必须扩展 JS Web 客户端并进行如下编辑:
openerp.your_module_name = function(instance) {
instance.web.WebClient.include({
init: function(parent, client_options) {
this._super(parent, client_options);
this.set('title_part', {"zopenerp": "Your Title"});
},
});
};
确保您执行了 odoo 包含 js 文件所需的所有操作,请参阅一些简单 Web 客户端模块的示例,例如网络对话框大小
通过这两项修改,您应该在所有 Odoo 页面中看到自定义页面标题。