콘텐츠로 건너뛰기
메뉴
커뮤니티에 참여하려면 회원 가입을 하시기 바랍니다.
신고된 질문입니다
1 회신
9327 화면

Hello I want to get my current model name

for example if \http://localhost:8069/web?debug=#id=123&view_type=form&model=hr.employee&action=432

it's hr.employee then i want to print it to console log.

 <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>

and 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);
    }
});
});

but i get error message

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"

can some one give me a hand?

아바타
취소
베스트 답변

You forgot to declare widget like this: 

Var Widget = require('web.Widget');

아바타
취소
관련 게시물 답글 화면 활동
0
1월 16
3453
0
7월 25
617
1
7월 25
5667
0
7월 25
1279
0
6월 25
1228