diff --git a/models.py b/models.py index 65482e7..d2e5ef2 100644 --- a/models.py +++ b/models.py @@ -53,7 +53,12 @@ class FetchMailImmediately(models.AbstractModel): @api.model def get_last_update_time(self): - return self.env['fetchmail.server'].sudo().search([]).run_time + res = self.env['fetchmail.server'].sudo().search([('state', '=', 'done')]) + array = [r.run_time for r in res] + if array: + return array[0] + else: + return None @api.model def run_fetchmail_manually(self): diff --git a/static/src/js/main.js b/static/src/js/main.js index aea39e7..20b07bd 100755 --- a/static/src/js/main.js +++ b/static/src/js/main.js @@ -38,8 +38,11 @@ openerp.mail_check_immediately = function(instance, local) { get_last_fetched_time: function(){ var _this = this; this.imm_model.call('get_last_update_time', {context: new instance.web.CompoundContext()}).then(function(res){ -// using jQuery timeago library - _this.$el.find('span.oe_view_manager_fetch_mail_imm_field').html($.timeago(res)); + var value; + if (res) + value = $.timeago(res); + value = value || 'undefined'; + _this.$el.find('span.oe_view_manager_fetch_mail_imm_field').html(value); }) },