Skip to main content

Odoo14: Cannot read property 'modelExtension' of undefined

I want to create a new view_type in Odoo 14. I followed these instructions: https://www.odoo.com/documentation/14.0/fr/developer/reference/javascript/javascript_cheatsheet.html#creating-a-new-field-widget and also this video: https://www.youtube.com/watch?v=SIoljYJhTqk&ab_channel=Odoo

I have this issue: TypeError: Cannot read property 'modelExtension' of undefined

My JS:

odoo.define("personal_calendar_view.PersonalCalendarView", function(require){
    "use_strict";

    var AbstractController = require("web.AbstractController");
    var AbstractModel = require("web.AbstractModel");
    var AbstractRenderer = require("web.AbstractRenderer");
    var AbstractView = require("web.AbstractView");
    var ViewRegistry = require("web.view_registry");

    var PersonalCalendarController = AbstractController.extend({});
    var PersonalCalendarRenderer = AbstractRenderer.extend({});
    var PersonalCalendarModel = AbstractModel.extend({});

    var PersonalCalendarView = AbstractView.extend({
        config: {
            Model: PersonalCalendarModel,
            Controller: PersonalCalendarController,
            Renderer: PersonalCalendarRenderer,
        },
        view_type: "personal_calendar",
    });

    ViewRegistry.add("personal_calendar", PersonalCalendarView);

    return PersonalCalendarView;
});

My python:

class View(models.Model):
    _inherit = 'ir.ui.view'

    type = fields.Selection(selection_add=[('personal_calendar', 'Personal calendar'),('general_calendar', 'General calendar')])

class ActWindowView(models.Model):
    _inherit = 'ir.actions.act_window.view'

    view_mode = fields.Selection(selection_add=[('personal_calendar', 'Personal calendar'),('general_calendar', 'General calendar')], ondelete={'personal_calendar': 'cascade','general_calendar':'cascade'})

And my XML:

<record id="view_planning_personal_calendar" model="ir.ui.view">
        <field name="name">planning.scheduler.personal.calendar</field>
        <field name="model">planning.scheduler</field>
        <field name="mode">primary</field>
        <field name="arch" type="xml">
            <personal_calendar>
                <field name="name"/>
                <field name="user_id"/>
            </personal_calendar>
        </field>
    </record>
<record model="ir.actions.act_window" id="action_personal_schedule">
        <field name="name">Personal Schedule</field>
        <field name="res_model">planning.scheduler</field>
        <field name="view_mode">personal_calendar</field>
        <field name="view_id" ref="view_planning_personal_calendar"/>
    </record>

The stacktrace is:

Uncaught (in promise) TypeError: Cannot read property 'modelExtension' of undefined
    at Class.init (web.assets_backend.js:1262)
    at Class.prototype.<computed> [as init] (web.assets_common.js:4632)
    at new Class (web.assets_common.js:4633)
    at Class._createViewController (web.assets_backend.js:452)
    at web.assets_backend.js:457
init @ web.assets_backend.js:1262
prototype.<computed> @ web.assets_common.js:4632
Class @ web.assets_common.js:4633
_createViewController @ web.assets_backend.js:452
(anonymous) @ web.assets_backend.js:457
setTimeout (async)
(anonymous) @ web.assets_common.js:1621
fire @ web.assets_common.js:1605
fireWith @ web.assets_common.js:1611
fire @ web.assets_common.js:1612
fire @ web.assets_common.js:1605
fireWith @ web.assets_common.js:1611
mightThrow @ web.assets_common.js:1618
process @ web.assets_common.js:1618
setTimeout (async)
(anonymous) @ web.assets_common.js:1621
fire @ web.assets_common.js:1605
fireWith @ web.assets_common.js:1611
fire @ web.assets_common.js:1612
fire @ web.assets_common.js:1605
fireWith @ web.assets_common.js:1611
done @ web.assets_common.js:2013
(anonymous) @ web.assets_common.js:2026
load (async)
send @ web.assets_common.js:2026
ajax @ web.assets_common.js:2005
(anonymous) @ web.assets_common.js:4587
_genericJsonRpc @ web.assets_common.js:4582
jsonRpc @ web.assets_common.js:4587
rpc @ web.assets_common.js:4588
query @ web.assets_common.js:4826
load_views @ web.assets_backend.js:597
load_views @ web.assets_backend.js:490
(anonymous) @ web.assets_common.js:4774
trigger @ web.assets_common.js:4772
_trigger_up @ web.assets_common.js:4778
_trigger_up @ web.assets_common.js:4778
trigger_up @ web.assets_common.js:4778
(anonymous) @ web.assets_common.js:4842
loadViews @ web.assets_common.js:4842
_loadViews @ web.assets_backend.js:461
_executeWindowAction @ web.assets_backend.js:453
_handleAction @ web.assets_backend.js:459
(anonymous) @ web.assets_common.js:4635
_handleAction @ web.assets_backend.js:479
(anonymous) @ web.assets_common.js:4635
(anonymous) @ web.assets_backend.js:421
Promise.then (async)
doAction @ web.assets_backend.js:421
do_action @ web.assets_backend.js:494
(anonymous) @ web.assets_backend.js:509
Promise.then (async)
on_hashchange @ web.assets_backend.js:509
new_handler @ web.assets_backend.js:313
dispatch @ web.assets_common.js:1726
elemData.handle @ web.assets_common.js:1712

Did someone had an idea?

Via Active questions tagged javascript - Stack Overflow https://ift.tt/2FdjaAW

Comments

Popular posts from this blog

Prop `className` did not match in next js app

I have written a sample code ( Github Link here ). this is a simple next js app, but giving me error when I refresh the page. This seems to be the common problem and I tried the fix provided in the internet but does not seem to fix my issue. The error is Warning: Prop className did not match. Server: "MuiBox-root MuiBox-root-1" Client: "MuiBox-root MuiBox-root-2". Did changes for _document.js, modified _app.js as mentioned in official website and solutions in stackoverflow. but nothing seems to work. Could someone take a look and help me whats wrong with the code? Via Active questions tagged javascript - Stack Overflow https://ift.tt/2FdjaAW

How to show number of registered users in Laravel based on usertype?

i'm trying to display data from the database in the admin dashboard i used this: <?php use Illuminate\Support\Facades\DB; $users = DB::table('users')->count(); echo $users; ?> and i have successfully get the correct data from the database but what if i want to display a specific data for example in this user table there is "usertype" that specify if the user is normal user or admin i want to user the same code above but to display a specific usertype i tried this: <?php use Illuminate\Support\Facades\DB; $users = DB::table('users')->count()->WHERE usertype =admin; echo $users; ?> but it didn't work, what am i doing wrong? source https://stackoverflow.com/questions/68199726/how-to-show-number-of-registered-users-in-laravel-based-on-usertype

Why is my reports service not connecting?

I am trying to pull some data from a Postgres database using Node.js and node-postures but I can't figure out why my service isn't connecting. my routes/index.js file: const express = require('express'); const router = express.Router(); const ordersCountController = require('../controllers/ordersCountController'); const ordersController = require('../controllers/ordersController'); const weeklyReportsController = require('../controllers/weeklyReportsController'); router.get('/orders_count', ordersCountController); router.get('/orders', ordersController); router.get('/weekly_reports', weeklyReportsController); module.exports = router; My controllers/weeklyReportsController.js file: const weeklyReportsService = require('../services/weeklyReportsService'); const weeklyReportsController = async (req, res) => { try { const data = await weeklyReportsService; res.json({data}) console