Update last commit when try to control possible concurrencies.
The queue need the instance by values. With the contraints and a control in the iteration mails will be enough.
This commit is contained in:
parent
c115b7b7b8
commit
c50dd002d8
11
activity.py
11
activity.py
|
@ -313,9 +313,18 @@ class Activity(metaclass=PoolMeta):
|
|||
def create_activity(cls):
|
||||
pool = Pool()
|
||||
ElectronicMail = pool.get('electronic.mail')
|
||||
ActivityConfiguration = pool.get('activity.configuration')
|
||||
|
||||
config = ActivityConfiguration(1)
|
||||
pending_mailbox = config.pending_mailbox
|
||||
|
||||
mails = ElectronicMail.search([
|
||||
('mailbox', '=', pending_mailbox)
|
||||
], order=[('date', 'ASC'), ('id', 'ASC')])
|
||||
|
||||
|
||||
with Transaction().set_context(queue_name=QUEUE_NAME):
|
||||
ElectronicMail.__queue__._create_activity()
|
||||
ElectronicMail.__queue__._create_activity(mails)
|
||||
|
||||
def get_previous_activity(self):
|
||||
ElectronicMail = Pool().get('electronic.mail')
|
||||
|
|
|
@ -19,7 +19,7 @@ class ElectronicMail(metaclass=PoolMeta):
|
|||
__name__ = 'electronic.mail'
|
||||
|
||||
@classmethod
|
||||
def _create_activity(cls):
|
||||
def _create_activity(cls, mails):
|
||||
pool = Pool()
|
||||
ModelData = pool.get('ir.model.data')
|
||||
Activity = pool.get('activity.activity')
|
||||
|
@ -29,19 +29,16 @@ class ElectronicMail(metaclass=PoolMeta):
|
|||
|
||||
config = ActivityConfiguration(1)
|
||||
employee = config.employee
|
||||
pending_mailbox = config.pending_mailbox
|
||||
processed_mailbox = config.processed_mailbox
|
||||
|
||||
activity_type = ActivityType(ModelData.get_id('activity',
|
||||
'incoming_email_type'))
|
||||
|
||||
mails = ElectronicMail.search([
|
||||
('mailbox', '=', pending_mailbox)
|
||||
], order=[('date', 'ASC'), ('id', 'ASC')])
|
||||
|
||||
activities = []
|
||||
activity_attachments = []
|
||||
for mail in mails:
|
||||
if mail.mailbox == processed_mailbox:
|
||||
continue
|
||||
activity = Activity()
|
||||
if mail.subject:
|
||||
activity.subject = mail.subject.replace('\r', '')
|
||||
|
|
Loading…
Reference in New Issue