summaryrefslogtreecommitdiff
path: root/addons/mail/wizard/mail_compose_message.py
diff options
context:
space:
mode:
authorRaphael Collet <rco@odoo.com>2019-08-14 07:35:49 +0000
committerDenis Ledoux <dle@odoo.com>2019-08-20 12:43:59 +0000
commit9920f20e4c7753bc17bea71dea3a90f7de687196 (patch)
tree6a3d0258c10a8ccb1d85949ddafdeb070de78121 /addons/mail/wizard/mail_compose_message.py
parente28d3aa4d3851d72deba08c236072d002f83216a (diff)
[IMP] models: ORM speedup
This branch is the combination of several optimizations in the ORM: * store field values once in the cache: the cache reflects more faithfully the database, only fields that explicitly depend on the context have an extra indirection in the cache; * delay recomputations by default: use method `recompute` to explicitly flush out pending recomputations; * delay updates in method `write`: updates are stored in a data structure that can be flushed efficiently to the database with method `flush` (which also flush out recomputations); * make method `modified` take advantage of inverse fields to inverse dependencies; * filter records by evaluating a domain on records in Python; * a computed field with `readonly=False` behaves like a normal field with an onchange method; * computed fields are computed in superuser mode by default. Work done by Toufik Ben Jaa, Raphael Collet, Denis Ledoux and Fabien Pinckaers. closes odoo/odoo#35659 Signed-off-by: Denis Ledoux <beledouxdenis@users.noreply.github.com>
Diffstat (limited to 'addons/mail/wizard/mail_compose_message.py')
-rw-r--r--addons/mail/wizard/mail_compose_message.py4
1 files changed, 3 insertions, 1 deletions
diff --git a/addons/mail/wizard/mail_compose_message.py b/addons/mail/wizard/mail_compose_message.py
index d3a33e8a7f1..aeeba8c2339 100644
--- a/addons/mail/wizard/mail_compose_message.py
+++ b/addons/mail/wizard/mail_compose_message.py
@@ -230,6 +230,7 @@ class MailComposer(models.TransientModel):
new_attachment_ids.append(attachment.copy({'res_model': 'mail.compose.message', 'res_id': wizard.id}).id)
else:
new_attachment_ids.append(attachment.id)
+ new_attachment_ids.reverse()
wizard.write({'attachment_ids': [(6, 0, new_attachment_ids)]})
# Mass Mailing
@@ -359,6 +360,7 @@ class MailComposer(models.TransientModel):
for attach_id in mail_values.pop('attachment_ids'):
new_attach_id = self.env['ir.attachment'].browse(attach_id).copy({'res_model': self._name, 'res_id': self.id})
attachment_ids.append(new_attach_id.id)
+ attachment_ids.reverse()
mail_values['attachment_ids'] = self.env['mail.thread']._message_post_process_attachments(
mail_values.pop('attachments', []),
attachment_ids,
@@ -416,7 +418,7 @@ class MailComposer(models.TransientModel):
}
attachment_ids.append(Attachment.create(data_attach).id)
if values.get('attachment_ids', []) or attachment_ids:
- values['attachment_ids'] = [(5,)] + values.get('attachment_ids', []) + attachment_ids
+ values['attachment_ids'] = [(6, 0, values.get('attachment_ids', []) + attachment_ids)]
else:
default_values = self.with_context(default_composition_mode=composition_mode, default_model=model, default_res_id=res_id).default_get(['composition_mode', 'model', 'res_id', 'parent_id', 'partner_ids', 'subject', 'body', 'email_from', 'reply_to', 'attachment_ids', 'mail_server_id'])
values = dict((key, default_values[key]) for key in ['subject', 'body', 'partner_ids', 'email_from', 'reply_to', 'attachment_ids', 'mail_server_id'] if key in default_values)