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

Confusion between commands.Bot and discord.Client | Which one should I use?

Whenever you look at YouTube tutorials or code from this website there is a real variation. Some developers use client = discord.Client(intents=intents) while the others use bot = commands.Bot(command_prefix="something", intents=intents) . Now I know slightly about the difference but I get errors from different places from my code when I use either of them and its confusing. Especially since there has a few changes over the years in discord.py it is hard to find the real difference. I tried sticking to discord.Client then I found that there are more features in commands.Bot . Then I found errors when using commands.Bot . An example of this is: When I try to use commands.Bot client = commands.Bot(command_prefix=">",intents=intents) async def load(): for filename in os.listdir("./Cogs"): if filename.endswith(".py"): client.load_extension(f"Cogs.{filename[:-3]}") The above doesnt giveany response from my Cogs ...

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

Where and how is this Laravel kernel constructor called? [closed]

Where and how is this Laravel kernel constructor called? public fucntion __construct(Application $app, $Router $roouter) { } I have read the documentation and some online tutorial but I can find any clear explanation. I am learning Laravel and I am wondering where does this kernel constructor receives its arguments from. "POSTMOTERM" CLARIFICATION: Here is more clarity.I have checked the boostrap/app.php and it is only used for boostrapping the interfaces into the container class. What is not clear to me is where and how the Kernel class is instatiated and the arguments passed to the object calling the constructor.Something similar to; obj = new kernel(arg1,arg2) or, is the framework using some magic functions somewhere? Special gratitude to those who burn their eyeballs and brain cells on this trivia before it goes into a full blown menopause alias "MARKED AS DUPLICATE". To some of the itchy-finger keyboard warriors, a.k.a The mods,because I believe in th...