1

I'm developing an Odoo module in which I add a button to existing module, this button when clicked should execute a certain function. Whenever I click this button, the function executes as desired but later I get an error: Cannot read property 'then' of undefined

The button definition in the view:

<button onclick="myclick()">Click me</button>

The JS Code (after simplification):

function myclick()
{
console.log("hi");
}

What I tried:

  • I simplified the code as much as I could but still the error appears.
  • I researched the error and I got some results about promises but I still don't know how to resolve this error.

enter image description here

4
  • Try returning something in the function, then is expecting a promise to be returned. stackoverflow.com/questions/24788171/… may give you a little more info. Commented Jul 20, 2018 at 13:28
  • You have to copy-paste the stack trace and the part of the code that this crashes on. Since this is Odoo enterprise we do not have access to it. Commented Jul 20, 2018 at 19:20
  • Maybe your click event is propagating to parent. Try stopping event propagation in onClick using e.stopPropagation() (note, e is an event - first arg of your myClick handler). Commented Jul 21, 2018 at 8:37
  • @ZbigniewZagórski .. Tried this but the error still exists. Commented Jul 22, 2018 at 8:23

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.