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

ValueError: X has 10 features, but LinearRegression is expecting 1 features as input

So, I am trying to predict the model but its throwing error like it has 10 features but it expacts only 1. So I am confused can anyone help me with it? more importantly its not working for me when my friend runs it. It works perfectly fine dose anyone know the reason about it? cv = KFold(n_splits = 10) all_loss = [] for i in range(9): # 1st for loop over polynomial orders poly_order = i X_train = make_polynomial(x, poly_order) loss_at_order = [] # initiate a set to collect loss for CV for train_index, test_index in cv.split(X_train): print('TRAIN:', train_index, 'TEST:', test_index) X_train_cv, X_test_cv = X_train[train_index], X_test[test_index] t_train_cv, t_test_cv = t[train_index], t[test_index] reg.fit(X_train_cv, t_train_cv) loss_at_order.append(np.mean((t_test_cv - reg.predict(X_test_cv))**2)) # collect loss at fold all_loss.append(np.mean(loss_at_order)) # collect loss at order plt.plot(np.log(al...

Sorting large arrays of big numeric stings

I was solving bigSorting() problem from hackerrank: Consider an array of numeric strings where each string is a positive number with anywhere from to digits. Sort the array's elements in non-decreasing, or ascending order of their integer values and return the sorted array. I know it works as follows: def bigSorting(unsorted): return sorted(unsorted, key=int) But I didnt guess this approach earlier. Initially I tried below: def bigSorting(unsorted): int_unsorted = [int(i) for i in unsorted] int_sorted = sorted(int_unsorted) return [str(i) for i in int_sorted] However, for some of the test cases, it was showing time limit exceeded. Why is it so? PS: I dont know exactly what those test cases were as hacker rank does not reveal all test cases. source https://stackoverflow.com/questions/73007397/sorting-large-arrays-of-big-numeric-stings

How to load Javascript with imported modules?

I am trying to import modules from tensorflowjs, and below is my code. test.html <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Document</title </head> <body> <script src="https://cdn.jsdelivr.net/npm/@tensorflow/tfjs@2.0.0/dist/tf.min.js"></script> <script type="module" src="./test.js"></script> </body> </html> test.js import * as tf from "./node_modules/@tensorflow/tfjs"; import {loadGraphModel} from "./node_modules/@tensorflow/tfjs-converter"; const MODEL_URL = './model.json'; const model = await loadGraphModel(MODEL_URL); const cat = document.getElementById('cat'); model.execute(tf.browser.fromPixels(cat)); Besides, I run the server using python -m http.server in my command prompt(Windows 10), and this is the error prompt in the console log of my browser: Failed to loa...