|
@ -14,10 +14,17 @@ class FetchMailServer(models.Model): |
|
|
|
|
|
|
|
|
_last_updated = None |
|
|
_last_updated = None |
|
|
|
|
|
|
|
|
run_time = fields.Datetime(string="Launch time") |
|
|
|
|
|
|
|
|
run_time = fields.Datetime(string="Launch time", compute='_run_time', store=False) |
|
|
|
|
|
|
|
|
|
|
|
@classmethod |
|
|
|
|
|
def _update_time(cls): |
|
|
|
|
|
|
|
|
|
|
|
cls._last_updated = tools.datetime.now() |
|
|
|
|
|
|
|
|
|
|
|
@api.one |
|
|
def _run_time(self): |
|
|
def _run_time(self): |
|
|
if not self._last_updated: |
|
|
if not self._last_updated: |
|
|
|
|
|
|
|
|
self._last_updated = tools.datetime.now() |
|
|
self._last_updated = tools.datetime.now() |
|
|
|
|
|
|
|
|
src_tstamp_str = self._last_updated.strftime(tools.misc.DEFAULT_SERVER_DATETIME_FORMAT) |
|
|
src_tstamp_str = self._last_updated.strftime(tools.misc.DEFAULT_SERVER_DATETIME_FORMAT) |
|
@ -26,7 +33,7 @@ class FetchMailServer(models.Model): |
|
|
dst_tz_name = self._context.get('tz') or self.env.user.tz |
|
|
dst_tz_name = self._context.get('tz') or self.env.user.tz |
|
|
_now = tools.misc.server_to_local_timestamp(src_tstamp_str, src_format, dst_format, dst_tz_name) |
|
|
_now = tools.misc.server_to_local_timestamp(src_tstamp_str, src_format, dst_format, dst_tz_name) |
|
|
|
|
|
|
|
|
return _now |
|
|
|
|
|
|
|
|
self.run_time = _now |
|
|
|
|
|
|
|
|
@api.model |
|
|
@api.model |
|
|
def _fetch_mails(self): |
|
|
def _fetch_mails(self): |
|
@ -37,10 +44,7 @@ class FetchMailServer(models.Model): |
|
|
raise exceptions.Warning(_('Error'), _('Task can be started no earlier than 5 seconds.')) |
|
|
raise exceptions.Warning(_('Error'), _('Task can be started no earlier than 5 seconds.')) |
|
|
|
|
|
|
|
|
super(FetchMailServer, self)._fetch_mails() |
|
|
super(FetchMailServer, self)._fetch_mails() |
|
|
|
|
|
|
|
|
res = self.env['fetchmail.server'].sudo().with_context(tz=self.env.user.tz).search([('state', '=', 'done')]) |
|
|
|
|
|
if res: |
|
|
|
|
|
res[0].run_time = self._run_time() |
|
|
|
|
|
|
|
|
self._update_time() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class FetchMailImmediately(models.AbstractModel): |
|
|
class FetchMailImmediately(models.AbstractModel): |
|
|