From 6ea0e61225d13bca28e47ab53ac2660d27dd3a07 Mon Sep 17 00:00:00 2001 From: Ivan Yelizariev Date: Sat, 20 Feb 2016 11:08:50 +0500 Subject: [PATCH] Revert "8.0 [DEL] group_menu_no_access:, res_users_clear_access_rights" --- __openerp__.py | 2 +- doc/changelog.rst | 9 +++++++++ models.py | 16 ++++++---------- 3 files changed, 16 insertions(+), 11 deletions(-) create mode 100644 doc/changelog.rst diff --git a/__openerp__.py b/__openerp__.py index 49f29d8..663ca66 100644 --- a/__openerp__.py +++ b/__openerp__.py @@ -1,6 +1,6 @@ { 'name' : 'Check mail immediately', - 'version' : '1.0.0', + 'version' : '1.0.1', 'author' : 'IT-Projects LLC, Ivan Yelizariev', 'license': 'LGPL-3', 'category' : 'Social Network', diff --git a/doc/changelog.rst b/doc/changelog.rst new file mode 100644 index 0000000..e72d492 --- /dev/null +++ b/doc/changelog.rst @@ -0,0 +1,9 @@ +.. _changelog: + +Changelog +========= + +`1.0.1` +------- + +- FIX: incorrectly displayed last updated time when multiple threads (--workers) \ No newline at end of file diff --git a/models.py b/models.py index 46d5d14..3306837 100644 --- a/models.py +++ b/models.py @@ -14,17 +14,10 @@ class FetchMailServer(models.Model): _last_updated = None - run_time = fields.Datetime(string="Launch time", compute='_run_time', store=False) + run_time = fields.Datetime(string="Launch time") - @classmethod - def _update_time(cls): - - cls._last_updated = tools.datetime.now() - - @api.one def _run_time(self): if not self._last_updated: - self._last_updated = tools.datetime.now() src_tstamp_str = self._last_updated.strftime(tools.misc.DEFAULT_SERVER_DATETIME_FORMAT) @@ -33,7 +26,7 @@ class FetchMailServer(models.Model): 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) - self.run_time = _now + return _now @api.model def _fetch_mails(self): @@ -44,7 +37,10 @@ class FetchMailServer(models.Model): raise exceptions.Warning(_('Error'), _('Task can be started no earlier than 5 seconds.')) super(FetchMailServer, self)._fetch_mails() - self._update_time() + + 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() class FetchMailImmediately(models.AbstractModel):