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

Ehab
  • 566
  • 6
  • 24
  • Try returning something in the function, `then` is expecting a promise to be returned. https://stackoverflow.com/questions/24788171/typeerror-cannot-read-property-then-of-undefined may give you a little more info. – Carson Jul 20 '18 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. – George Daramouskas Jul 20 '18 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). – Zbigniew Zagórski Jul 21 '18 at 08:37
  • @ZbigniewZagórski .. Tried this but the error still exists. – Ehab Jul 22 '18 at 08:23

0 Answers0