您好,我想获取当前的型号名称
例如,如果 http://localhost:8069/web?debug=#id=123&view_type=form&model=hr.employee&action=432
是hr.employee,然后我想将其打印到控制台日志中。
<template id="res_partner_lt.assets_backend" name="res_partner_lt assets" inherit_id="web.assets_backend" >
<xpath expr="." position="inside" >
<script type="text/javascript" src="/res_partner_lt/static/src/js/hr_view.js" ></script>
</xpath>
</template>
和JavaScript
odoo.define('res_partner_lt.HrView', function (require) {
"use strict";
var ViewManager = Widget.extend(ControlPanelMixin, {
template: "ViewManager",
switch_mode: function(view_type, no_store, view_options) {
// To get Current Module Name
console.log("Module Name" +this.dataset.model);
// some other code
return this._super(view_type, no_store, view_options);
}
});
});
但我收到错误消息
error: Some modules could not be started
error: ReferenceError: Widget is not defined at http://localhost:8069/res_partner_lt/static/src/js/hr_view.js:4:19 at process_job (http://localhost:8069/web/static/src/js/boot.js:210:44) at Object.process_jobs (http://localhost:8069/web/static/src/js/boot.js:252:17) at Object.define (http://localhost:8069/web/static/src/js/boot.js:140:18) at http://localhost:8069/res_partner_lt/static/src/js/hr_view.js:1:6
message: "Widget is not defined"
有人可以帮我吗?
答案 0 :(得分:0)
忘记声明小部件和ControlPanelMixin
var ControlPanelMixin = require('web.ControlPanelMixin');
var Widget = require('web.Widget');