Skip to Content
Menu
This question has been flagged
1 Reply
7885 Views

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?

Avatar
Discard
Best Answer

You forgot to declare widget like this: 

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

Avatar
Discard
Related Posts Replies Views Activity
0
Jan 16
2381
0
Dec 24
41
1
Dec 24
132
2
Nov 24
86
1
Oct 24
267