12

I need to run some javascript code to check when odoo has ended loading.

I know that querying jQuery.active == 0 does the trick in version 7 but that does not work in odoo because it always keep one connection open for the longpolling.

Does anybody know which web element can I use to check for sure when the interface is fully loaded ?

If I can query the URL of the active jQuery connections that would also do the trick.

Adrian Cid Almaguer
  • 7,815
  • 13
  • 41
  • 63
yucer
  • 4,431
  • 3
  • 34
  • 42
  • What about $(window).load() ? – Alexander Johansen May 18 '15 at 08:18
  • well then you need to post some existing code. we can't assume what is happening at your end. yet i want to tell you that if there are some async calls then you can use `$.when().then()` to chain it to proceed in a chained manner. – Jai May 18 '15 at 08:20
  • I am trying to do this: http://agilesoftwaretesting.com/selenium-wait-for-ajax-the-right-way/ The code is there in step 5: selenium.browserbot.getCurrentWindow().jQuery.active == 0 – yucer May 18 '15 at 09:58
  • I need to check the condition at any time, in order to know if odoo is not expecting responses from the server (other than longpolling request, of course) – yucer May 18 '15 at 10:01
  • open the javascript console of the browser with CTRL+SHIFT+I when odoo is loaded and quiet. If you can put there a javascript expression that evaluates to true and would evaluate to false while loading something of the interface, the problem is solved. – yucer May 18 '15 at 10:11
  • @yucer you got some advance? – Adrian Cid Almaguer Jun 06 '15 at 18:08
  • @Jai : I have added no custom code to odoo, since i am trying to test it. You can try the last release of odoo v8. I am just looking for a JavaScript expression to check one condition: "Odoo interface is quiet and nothing remains to load". This "quiet" concept exclude the longpolling requests for instant messaging. – yucer Jun 08 '15 at 00:33
  • @AlexanderJohansen please read my answer to oMiKey's question. – yucer Jun 08 '15 at 07:11
  • @yucer Did you find a solution ? I'm facing the same problem in Odoo v9 – Ahmed T. Ali Mar 27 '16 at 17:17
  • No, I did not. I have to make some time to solve this. As a temporary solution we try more times. The solution would allow to safe resource usage during tests. It helps a little to disable the chron jobs while making the tests. Also anything that can Introduce random extra time. – yucer Mar 31 '16 at 00:37
  • I was trying something with the $.ajaxPrefilter(). But I have to elaborate it more. – yucer Mar 31 '16 at 00:40

1 Answers1

7

I don´t know odoo but I supose that you can wait for a variable in odoo and do this:

function checkodoo() {
   if ('undefined' !== typeof odooVariableThatYouWatch ) {
       clearInterval(intervalOdoo);
       lauchYourStaff();
   }
}

var intervalOdoo = setInterval("checkodoo()",100);

If on https://www.odoo.com the variable is openerp

I look the variable here: https://www.odoo.com/documentation/8.0/howtos/web.html

user568021
  • 1,426
  • 5
  • 28
  • 55
Raúl Martín
  • 4,471
  • 3
  • 23
  • 42
  • Do you mean that the openerp variable is destroyed on every user interaction (Ex: a user clicks on a menu item) and it's the last element to be assigned after all needed elements are reloaded ? – yucer Jun 08 '15 at 07:15
  • By the way... The question is not about waiting. It's about the expression to wait for. Would your answer be 'undefined' !== typeof openerp ? – yucer Jun 08 '15 at 07:16