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.

55 lines
1.5 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. instance.mail.Wall.include({
  3. init: function(){
  4. this._super.apply(this, arguments);
  5. var _this = this;
  6. this.imm_model = new instance.web.Model('fetch_mail.imm');
  7. this.events['click a.oe_fetch_new_mails'] = function(){
  8. _this.run_fetchmail_manually();
  9. };
  10. },
  11. start: function() {
  12. var _this = this;
  13. this._super();
  14. this.get_last_fetched_time();
  15. this.get_time_loop = setInterval(function(){
  16. _this.get_last_fetched_time();
  17. }, 30000);
  18. },
  19. run_fetchmail_manually: function(){
  20. var _this = this;
  21. this.imm_model.call('run_fetchmail_manually', {context: new instance.web.CompoundContext()}).then(function(){
  22. _this.get_last_fetched_time();
  23. });
  24. },
  25. get_last_fetched_time: function(){
  26. var _this = this;
  27. this.imm_model.call('get_last_update_time', {context: new instance.web.CompoundContext()}).then(function(res){
  28. var value;
  29. if (res)
  30. value = $.timeago(res);
  31. value = value || 'undefined';
  32. _this.$el.find('span.oe_view_manager_fetch_mail_imm_field').html(value);
  33. });
  34. },
  35. destroy: function(){
  36. clearInterval(this.get_time_loop);
  37. this._super.apply(this, arguments);
  38. }
  39. });
  40. };