mirror of
https://github.com/NaN-tic/trytond-electronic_mail_activity.git
synced 2023-12-14 04:02:57 +01:00
30 lines
1 KiB
Python
30 lines
1 KiB
Python
# The COPYRIGHT file at the top level of this repository contains the full
|
|
# copyright notices and license terms.
|
|
from trytond.pool import Pool, PoolMeta
|
|
from trytond.model import fields
|
|
|
|
__all__ = ['IMAPServer']
|
|
|
|
|
|
class IMAPServer(metaclass=PoolMeta):
|
|
__name__ = 'imap.server'
|
|
|
|
employee = fields.Many2One('company.employee', 'Default Employee')
|
|
|
|
@classmethod
|
|
def fetch_mails(cls, servers):
|
|
Activity = Pool().get('activity.activity')
|
|
activity_servers = []
|
|
other_servers = []
|
|
for server in servers:
|
|
if server.model and server.model.model == 'activity.activity':
|
|
activity_servers.append(server)
|
|
else:
|
|
other_servers.append(server)
|
|
mails = {}
|
|
if activity_servers:
|
|
mails.update(super(IMAPServer, cls).fetch_mails(activity_servers))
|
|
Activity.create_activity(mails)
|
|
if other_servers:
|
|
mails.update(super(IMAPServer, cls).fetch_mails(other_servers))
|
|
return mails
|