如何在 webclient odoo 中覆盖 javascript 函数"_title_changed"



我的目标是使用公司名称更改Page标题。我试图改变功能,但仍然没有效果。对如何实现这个有什么想法吗?

var session = require('web.session');
var AbstractWebClient = require('web.AbstractWebClient');
AbstractWebClient.include({
_title_changed: function () {
this._super();
var company_name = session.user_companies.current_company[1];
document.title = company_name;
console.log('_title_changed function');
},
});

我缺少的是oo.define()。

我是这样做的:

odoo.define('my_module.AbstractWebClient', function (require) {
"use strict";

/**
* AbstractWebClient Override Method for Page Title
*/
var session = require('web.session');
var AbstractWebClient = require('web.AbstractWebClient');
AbstractWebClient.include({
_title_changed: function () {
this._super();
var company_name = session.user_companies.current_company[1];
document.title = company_name;
console.log('_title_changed function');
},
});
return AbstractWebClient;
});

最新更新