summaryrefslogtreecommitdiff
path: root/addons/fetchmail
diff options
context:
space:
mode:
authorRavish (Open ERP) <rmu@tinyerp.com>2013-05-16 10:44:37 +0530
committerRavish (Open ERP) <rmu@tinyerp.com>2013-05-16 10:44:37 +0530
commitfa9f18359fccc836a460736d2d07fe9b9ba0463a (patch)
tree24f77e99fd00eee9f8ed833b4ad45aee22f628a7 /addons/fetchmail
parentdd81c8f9c340ed78db09f3c9c0b273ad86faa056 (diff)
parent1bb278384c4a3e6053a8f9072f4515d2e42d0455 (diff)
[merge] with lateset 7.0
bzr revid: rmu@tinyerp.com-20130516051437-1bdcjgxey3efpw31
Diffstat (limited to 'addons/fetchmail')
-rw-r--r--addons/fetchmail/fetchmail.py27
-rw-r--r--addons/fetchmail/fetchmail_data.xml2
-rw-r--r--addons/fetchmail/i18n/lt.po20
-rw-r--r--addons/fetchmail/i18n/nl.po8
4 files changed, 41 insertions, 16 deletions
diff --git a/addons/fetchmail/fetchmail.py b/addons/fetchmail/fetchmail.py
index 4edba8cbe3c..d408e7da9ac 100644
--- a/addons/fetchmail/fetchmail.py
+++ b/addons/fetchmail/fetchmail.py
@@ -90,7 +90,6 @@ class fetchmail_server(osv.osv):
'script': '/mail/static/scripts/openerp_mailgate.py',
}
-
def onchange_server_type(self, cr, uid, ids, server_type=False, ssl=False, object_id=False):
port = 0
values = {}
@@ -176,13 +175,14 @@ openerp_mailgate: "|/path/to/openerp-mailgate.py --host=localhost -u %(uid)d -p
def _fetch_mails(self, cr, uid, ids=False, context=None):
if not ids:
- ids = self.search(cr, uid, [('state','=','done')])
+ ids = self.search(cr, uid, [('state','=','done'),('type','in',['pop','imap'])])
return self.fetch_mail(cr, uid, ids, context=context)
def fetch_mail(self, cr, uid, ids, context=None):
"""WARNING: meant for cron usage only - will commit() after each email!"""
if context is None:
context = {}
+ context['fetchmail_cron_running'] = True
mail_thread = self.pool.get('mail.thread')
action_pool = self.pool.get('ir.actions.server')
for server in self.browse(cr, uid, ids, context=context):
@@ -241,6 +241,29 @@ openerp_mailgate: "|/path/to/openerp-mailgate.py --host=localhost -u %(uid)d -p
server.write({'date': time.strftime(tools.DEFAULT_SERVER_DATETIME_FORMAT)})
return True
+ def cron_update(self, cr, uid, context=None):
+ if context is None:
+ context = {}
+ if not context.get('fetchmail_cron_running'):
+ # Enabled/Disable cron based on the number of 'done' server of type pop or imap
+ ids = self.search(cr, uid, [('state','=','done'),('type','in',['pop','imap'])])
+ try:
+ cron_id = self.pool.get('ir.model.data').get_object_reference(cr, uid, 'fetchmail', 'ir_cron_mail_gateway_action')[1]
+ self.pool.get('ir.cron').write(cr, 1, [cron_id], {'active': bool(ids)})
+ except ValueError:
+ # Nevermind if default cron cannot be found
+ pass
+
+ def create(self, cr, uid, values, context=None):
+ res = super(fetchmail_server, self).create(cr, uid, values, context=context)
+ self.cron_update(cr, uid, context=context)
+ return res
+
+ def write(self, cr, uid, ids, values, context=None):
+ res = super(fetchmail_server, self).write(cr, uid, ids, values, context=context)
+ self.cron_update(cr, uid, context=context)
+ return res
+
class mail_mail(osv.osv):
_inherit = "mail.mail"
_columns = {
diff --git a/addons/fetchmail/fetchmail_data.xml b/addons/fetchmail/fetchmail_data.xml
index d77aadc12de..3f6592b340f 100644
--- a/addons/fetchmail/fetchmail_data.xml
+++ b/addons/fetchmail/fetchmail_data.xml
@@ -10,6 +10,8 @@
<field name="model">fetchmail.server</field>
<field name="function">_fetch_mails</field>
<field name="args">()</field>
+ <!-- Active flag is set on fetchmail_server.create/write -->
+ <field name="active" eval="False"/>
</record>
</data>
</openerp>
diff --git a/addons/fetchmail/i18n/lt.po b/addons/fetchmail/i18n/lt.po
index 7c59333fc94..7f30806b988 100644
--- a/addons/fetchmail/i18n/lt.po
+++ b/addons/fetchmail/i18n/lt.po
@@ -1,21 +1,21 @@
# Lithuanian translation for openobject-addons
# Copyright (c) 2012 Rosetta Contributors and Canonical Ltd 2012
# This file is distributed under the same license as the openobject-addons package.
-# FIRST AUTHOR <EMAIL@ADDRESS>, 2012.
+# Giedrius Slavinskas <giedrius@inovera.lt>, 2012.
#
msgid ""
msgstr ""
"Project-Id-Version: openobject-addons\n"
"Report-Msgid-Bugs-To: FULL NAME <EMAIL@ADDRESS>\n"
"POT-Creation-Date: 2013-03-07 08:38+0000\n"
-"PO-Revision-Date: 2012-12-21 23:00+0000\n"
-"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
+"PO-Revision-Date: 2013-04-30 16:27+0000\n"
+"Last-Translator: Giedrius Slavinskas - inovera.lt <giedrius@inovera.lt>\n"
"Language-Team: Lithuanian <lt@li.org>\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
-"X-Launchpad-Export-Date: 2013-03-28 05:39+0000\n"
-"X-Generator: Launchpad (build 16546)\n"
+"X-Launchpad-Export-Date: 2013-05-01 05:14+0000\n"
+"X-Generator: Launchpad (build 16580)\n"
#. module: fetchmail
#: selection:fetchmail.server,state:0
@@ -96,7 +96,7 @@ msgstr ""
#. module: fetchmail
#: field:fetchmail.server,state:0
msgid "Status"
-msgstr ""
+msgstr "Būsena"
#. module: fetchmail
#: model:ir.model,name:fetchmail.model_fetchmail_server
@@ -149,7 +149,7 @@ msgstr ""
#: view:fetchmail.server:0
#: field:fetchmail.server,configuration:0
msgid "Configuration"
-msgstr ""
+msgstr "Nustatymai"
#. module: fetchmail
#: field:fetchmail.server,script:0
@@ -170,7 +170,7 @@ msgstr ""
#. module: fetchmail
#: field:fetchmail.server,user:0
msgid "Username"
-msgstr ""
+msgstr "Naudotojo vardas"
#. module: fetchmail
#: help:fetchmail.server,server:0
@@ -209,7 +209,7 @@ msgstr ""
#: field:fetchmail.server,message_ids:0
#: model:ir.actions.act_window,name:fetchmail.act_server_history
msgid "Messages"
-msgstr "Žinutė"
+msgstr "Pranešimai"
#. module: fetchmail
#: view:fetchmail.server:0
@@ -286,7 +286,7 @@ msgstr ""
#. module: fetchmail
#: view:fetchmail.server:0
msgid "Advanced"
-msgstr ""
+msgstr "Išsamūs"
#. module: fetchmail
#: view:fetchmail.server:0
diff --git a/addons/fetchmail/i18n/nl.po b/addons/fetchmail/i18n/nl.po
index d9c5b0063a0..7a58e41df20 100644
--- a/addons/fetchmail/i18n/nl.po
+++ b/addons/fetchmail/i18n/nl.po
@@ -8,14 +8,14 @@ msgstr ""
"Project-Id-Version: openobject-addons\n"
"Report-Msgid-Bugs-To: FULL NAME <EMAIL@ADDRESS>\n"
"POT-Creation-Date: 2013-03-07 08:38+0000\n"
-"PO-Revision-Date: 2013-03-02 17:42+0000\n"
+"PO-Revision-Date: 2013-05-01 18:12+0000\n"
"Last-Translator: Erwin van der Ploeg (Endian Solutions) <Unknown>\n"
"Language-Team: Dutch <nl@li.org>\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
-"X-Launchpad-Export-Date: 2013-03-28 05:39+0000\n"
-"X-Generator: Launchpad (build 16546)\n"
+"X-Launchpad-Export-Date: 2013-05-02 06:08+0000\n"
+"X-Generator: Launchpad (build 16580)\n"
#. module: fetchmail
#: selection:fetchmail.server,state:0
@@ -71,7 +71,7 @@ msgstr ""
#. module: fetchmail
#: view:base.config.settings:0
msgid "Configure the incoming email gateway"
-msgstr "De inkomende e-mail gateway instellen."
+msgstr "Inkomende e-mail server instellen"
#. module: fetchmail
#: view:fetchmail.server:0