s0x90
10 years ago
6 changed files with 50 additions and 54 deletions
@ -1,2 +0,0 @@ |
|||
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink |
|||
access_fetchmail_server,fetchmail.server,model_fetchmail_server,base.group_user,1,1,1,1 |
@ -1,42 +1,55 @@ |
|||
openerp.mail_check_immediately = function(instance, local) { |
|||
|
|||
instance.mail.Wall.include({ |
|||
|
|||
init: function(){ |
|||
this._super.apply(this, arguments); |
|||
|
|||
var _this = this; |
|||
var fetchmailTimerId; |
|||
|
|||
this.events['click a.oe_fetch_new_mails'] = function(){ |
|||
_this.get_fetchmail_obj(); |
|||
} |
|||
}, |
|||
|
|||
start: function() { |
|||
this._super(); |
|||
this.get_last_update_time(); |
|||
this.get_last_fetchedmail_time(); |
|||
this.get_time_loop() |
|||
}, |
|||
|
|||
events: { |
|||
'click a.oe_fetch_new_mails': function(){ |
|||
this.get_fetchmail_obj(); |
|||
} |
|||
}, |
|||
|
|||
get_fetchmail_obj: function(){ |
|||
var model = new instance.web.Model('fetch_mail.imm'); |
|||
var _this = this; |
|||
|
|||
model.call('run_fetchmail_manually', {context: new instance.web.CompoundContext()}).then(function(){ |
|||
_this.get_last_update_time() |
|||
_this.get_last_fetchedmail_time() |
|||
}) |
|||
}, |
|||
|
|||
get_last_update_time: function(){ |
|||
get_last_fetchedmail_time: function(){ |
|||
var _this = this; |
|||
var fetchmail = new instance.web.Model('fetchmail.server'); |
|||
var model = new instance.web.Model('fetch_mail.imm'); |
|||
|
|||
fetchmail.query(['run_time']).all().then(function(res){ |
|||
_this.$el.find('span.oe_view_manager_fetch_mail_imm_field').html(res[0].run_time); |
|||
model.call('get_last_update_time', {context: new instance.web.CompoundContext()}).then(function(res){ |
|||
_this.$el.find('span.oe_view_manager_fetch_mail_imm_field').html(res); |
|||
console.log(res) |
|||
}) |
|||
|
|||
}, |
|||
|
|||
get_time_loop: function(){ |
|||
var _this = this; |
|||
setInterval(function(){ |
|||
_this.get_last_update_time() |
|||
}, 30000) |
|||
fetchmailTimerId = setInterval(function(){ |
|||
_this.get_last_fetchedmail_time() |
|||
}, 30000); |
|||
}, |
|||
|
|||
destroy: function(){ |
|||
clearInterval(fetchmailTimerId); |
|||
this._super.apply(this, arguments); |
|||
} |
|||
|
|||
}); |
|||
}; |
Write
Preview
Loading…
Cancel
Save
Reference in new issue