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

I want to show alert box on button click but getting error iam sharing all files and error.

Wizard.js

odoo.define('wizard.wizard', function (require) {

"use strict";

var ajax = require('web.ajax');

var core = require('web.core');

var Dialog = require("web.Dialog");

var Widget = require("web.Widget");

var rpc = require("web.rpc");

var _t = core._t;

var PaymentForm = Widget.extend({

initialize: function () {

alert('End');

},

events: {

'click #o_payment_form_add_pm': 'addPmEvent'

},

addPmEvent: function (ev) {

ev.stopPropagation();

ev.preventDefault();

alert('click');

},

});

alert('start');

});

Wizard.xml

<template id="assets_frontend" inherit_id="web.assets_backend" name="wizard2">

<xpath expr="." position="inside">

<script type="text/javascript" src="/wizard/static/src/js/wizard.js"></script>

</xpath>

</template>

<record model="ir.ui.view" id="wizard_form_view">

<field name="name">wizard.form</field>

<field name="model">wizard</field>

<field name="arch" type="xml">

<form string="wizard">

<header>

<button name="reload_on_button" string="call web service" class="your_class"/> <!--type="object"-->

<button id="o_payment_form_add_pm" string="js" class="btn btn-primary btn-lg mb8 mt8"/>

</header>

<sheet>

<group>

<group string="">

<field name="wizardname" > </field>

<field name="current_date" > </field>

</group>

</group>

</sheet>

</form>

</field>

</record>

ERROR

Uncaught TypeError: Cannot read property 'then' of undefined

http://localhost:8069/web/content/434-7301179/web.assets_backend.js:471

Traceback:

TypeError: Cannot read property 'then' of undefined

at Class.execute_action (http://localhost:8069/web/content/434-7301179/web.assets_backend.js:471:684)

at Class.<anonymous> (http://localhost:8069/web/content/365-3f13533/web.assets_common.js:3908:11)

at Class.trigger (http://localhost:8069/web/content/365-3f13533/web.assets_common.js:3906:180)

at Class._trigger_up (http://localhost:8069/web/content/365-3f13533/web.assets_common.js:3912:365)

at Class._trigger_up (http://localhost:8069/web/content/365-3f13533/web.assets_common.js:3912:449)

at Class.trigger_up (http://localhost:8069/web/content/365-3f13533/web.assets_common.js:3912:280)

at Class._callButtonAction (http://localhost:8069/web/content/434-7301179/web.assets_backend.js:1263:1694)

at Object.<anonymous> (http://localhost:8069/web/content/434-7301179/web.assets_backend.js:1363:992)

at Object.<anonymous> (http://localhost:8069/web/content/365-3f13533/web.assets_common.js:802:681)

at fire (http://localhost:8069/web/content/365-3f13533/web.assets_common.js:796:299)

아바타
취소
베스트 답변

hi! Have you found any solution?

아바타
취소
베스트 답변

Not sure if it is the issue, but it strikes me as odd. For the Widget class it uses the function init, not initialize. You should also be calling super whenever extending a function on a class you are extending. Adding the following in the new init function should help:

this._super.apply(this, arguments);

Also, whenever debugging JavaScript use 'Developer mode with Assets' as it really helps pinpoint in which JS file the error occurred.

Regards,
Jake Robinson
Dionysus Software

아바타
취소