You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

60 lines
1.8 KiB

9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
  1. openerp.mail_check_immediately = function(instance, local) {
  2. "use strict";
  3. instance.mail.Wall.include({
  4. init: function() {
  5. this._super.apply(this, arguments);
  6. var _this = this;
  7. this.imm_model = new instance.web.Model("fetch_mail.imm");
  8. this.events["click a.oe_fetch_new_mails"] = function() {
  9. _this.run_fetchmail_manually();
  10. };
  11. },
  12. start: function() {
  13. var _this = this;
  14. this._super();
  15. this.get_last_fetched_time();
  16. this.get_time_loop = setInterval(function() {
  17. _this.get_last_fetched_time();
  18. }, 30000);
  19. },
  20. run_fetchmail_manually: function() {
  21. var _this = this;
  22. this.imm_model
  23. .call("run_fetchmail_manually", {
  24. context: new instance.web.CompoundContext(),
  25. })
  26. .then(function() {
  27. _this.get_last_fetched_time();
  28. });
  29. },
  30. get_last_fetched_time: function() {
  31. var _this = this;
  32. this.imm_model
  33. .call("get_last_update_time", {
  34. context: new instance.web.CompoundContext(),
  35. })
  36. .then(function(res) {
  37. var value = null;
  38. if (res) value = $.timeago(res);
  39. value = value || "undefined";
  40. _this.$el
  41. .find("span.oe_view_manager_fetch_mail_imm_field")
  42. .html(value);
  43. });
  44. },
  45. destroy: function() {
  46. clearInterval(this.get_time_loop);
  47. this._super.apply(this, arguments);
  48. },
  49. });
  50. };