Skip to Content
Odoo Menu
  • Sign in
  • Try it free
  • Apps
    Finance
    • Accounting
    • Invoicing
    • Expenses
    • Spreadsheet (BI)
    • Documents
    • Sign
    Sales
    • CRM
    • Sales
    • POS Shop
    • POS Restaurant
    • Subscriptions
    • Rental
    Websites
    • Website Builder
    • eCommerce
    • Blog
    • Forum
    • Live Chat
    • eLearning
    Supply Chain
    • Inventory
    • Manufacturing
    • PLM
    • Purchase
    • Maintenance
    • Quality
    Human Resources
    • Employees
    • Recruitment
    • Time Off
    • Appraisals
    • Referrals
    • Fleet
    Marketing
    • Social Marketing
    • Email Marketing
    • SMS Marketing
    • Events
    • Marketing Automation
    • Surveys
    Services
    • Project
    • Timesheets
    • Field Service
    • Helpdesk
    • Planning
    • Appointments
    Productivity
    • Discuss
    • Approvals
    • IoT
    • VoIP
    • Knowledge
    • WhatsApp
    Third party apps Odoo Studio Odoo Cloud Platform
  • Industries
    Retail
    • Book Store
    • Clothing Store
    • Furniture Store
    • Grocery Store
    • Hardware Store
    • Toy Store
    Food & Hospitality
    • Bar and Pub
    • Restaurant
    • Fast Food
    • Guest House
    • Beverage Distributor
    • Hotel
    Real Estate
    • Real Estate Agency
    • Architecture Firm
    • Construction
    • Estate Management
    • Gardening
    • Property Owner Association
    Consulting
    • Accounting Firm
    • Odoo Partner
    • Marketing Agency
    • Law firm
    • Talent Acquisition
    • Audit & Certification
    Manufacturing
    • Textile
    • Metal
    • Furnitures
    • Food
    • Brewery
    • Corporate Gifts
    Health & Fitness
    • Sports Club
    • Eyewear Store
    • Fitness Center
    • Wellness Practitioners
    • Pharmacy
    • Hair Salon
    Trades
    • Handyman
    • IT Hardware & Support
    • Solar Energy Systems
    • Shoe Maker
    • Cleaning Services
    • HVAC Services
    Others
    • Nonprofit Organization
    • Environmental Agency
    • Billboard Rental
    • Photography
    • Bike Leasing
    • Software Reseller
    Browse all Industries
  • Community
    Learn
    • Tutorials
    • Documentation
    • Certifications
    • Training
    • Blog
    • Podcast
    Empower Education
    • Education Program
    • Scale Up! Business Game
    • Visit Odoo
    Get the Software
    • Download
    • Compare Editions
    • Releases
    Collaborate
    • Github
    • Forum
    • Events
    • Translations
    • Become a Partner
    • Services for Partners
    • Register your Accounting Firm
    Get Services
    • Find a Partner
    • Find an Accountant
    • Meet an advisor
    • Implementation Services
    • Customer References
    • Support
    • Upgrades
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Get a demo
  • Pricing
  • Help

Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:

  • CRM
  • e-Commerce
  • Accounting
  • Inventory
  • PoS
  • Project
  • MRP
All apps
You need to be registered to interact with the community.
All Posts People Badges
Tags (View all)
odoo accounting v14 pos v15
About this forum
You need to be registered to interact with the community.
All Posts People Badges
Tags (View all)
odoo accounting v14 pos v15
About this forum
Help

Want to show alert on button click using JS in odoo 11 but getting error.

Subscribe

Get notified when there's activity on this post

This question has been flagged
2 Replies
9905 Views
Avatar
Fawad Mazhar

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)

0
Avatar
Discard
Avatar
Zahid Mehmood
Best Answer

hi! Have you found any solution?

0
Avatar
Discard
Avatar
Jake Robinson
Best Answer

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

0
Avatar
Discard
Enjoying the discussion? Don't just read, join in!

Create an account today to enjoy exclusive features and engage with our awesome community!

Sign up
Community
  • Tutorials
  • Documentation
  • Forum
Open Source
  • Download
  • Github
  • Runbot
  • Translations
Services
  • Odoo.sh Hosting
  • Support
  • Upgrade
  • Custom Developments
  • Education
  • Find an Accountant
  • Find a Partner
  • Become a Partner
About us
  • Our company
  • Brand Assets
  • Contact us
  • Jobs
  • Events
  • Podcast
  • Blog
  • Customers
  • Legal • Privacy
  • Security
الْعَرَبيّة Català 简体中文 繁體中文 (台灣) Čeština Dansk Nederlands English Suomi Français Deutsch हिंदी Bahasa Indonesia Italiano 日本語 한국어 (KR) Lietuvių kalba Język polski Português (BR) română русский язык Slovenský jazyk slovenščina Español (América Latina) Español ภาษาไทย Türkçe українська Tiếng Việt

Odoo is a suite of open source business apps that cover all your company needs: CRM, eCommerce, accounting, inventory, point of sale, project management, etc.

Odoo's unique value proposition is to be at the same time very easy to use and fully integrated.

Website made with

Odoo Experience on YouTube

1. Use the live chat to ask your questions.
2. The operator answers within a few minutes.

Live support on Youtube
Watch now