summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThibault Delavallée <tde@openerp.com>2012-09-06 15:42:01 +0200
committerThibault Delavallée <tde@openerp.com>2012-09-06 15:42:01 +0200
commit9b9bdae9e008e930eaf1cf208b90f66bdbdf4e7d (patch)
tree7b222d9d89e8c2c8c17f46d3cb0b847dbcb35236
parenta1fe4532239a343054e0d3a05df94dd68f7ac359 (diff)
[IMP] composer: attachments are attached to the mail.compose.message record, not the related document anymore. This way, when deleting the mail.compose.message, attachments will be unlinked. Added deletion cascaded to res_model and res_id = 0, because of attachments added on a not-already-saved composer. BTW, cleaned mail/__openerp__.py.
bzr revid: tde@openerp.com-20120906134201-8845xov0mjbxh8mr
-rw-r--r--addons/mail/__openerp__.py12
-rw-r--r--addons/mail/mail_message.py9
-rw-r--r--addons/mail/static/src/xml/mail.xml4
-rw-r--r--addons/mail/wizard/mail_compose_message.py2
4 files changed, 15 insertions, 12 deletions
diff --git a/addons/mail/__openerp__.py b/addons/mail/__openerp__.py
index 99dd6bda6ac..08a98cb0a02 100644
--- a/addons/mail/__openerp__.py
+++ b/addons/mail/__openerp__.py
@@ -30,27 +30,27 @@ A business oriented Social Networking with a fully-integrated email and message
===========================================================================================
The Social Networking module provides an unified social network
-abstraction layer allowing applications to display a complete
+abstraction layer allowing applications to display a complete
communication history on documents. It gives the users the possibility
to read and send messages and emails in an unified way.
-It also provides a feeds page combined to a subscription mechanism, that
+It also provides a feeds page combined to a subscription mechanism, that
allows to follow documents, and to be constantly updated about recent
news.
-
+
The main features of the module are:
------------------------------------
* a clean and renewed communication history for any OpenERP
document that can act as a discussion topic,
* a discussion mean on documents,
- * a subscription mechanism to be updated about new messages on
+ * a subscription mechanism to be updated about new messages on
interesting documents,
- * an unified feeds page to see recent messages and activity
+ * an unified feeds page to see recent messages and activity
on followed documents,
* user communication through the feeds page,
* a threaded discussion design,
* relies on the global outgoing mail server, an integrated email
- management system allowing to send emails with a configurable
+ management system allowing to send emails with a configurable
scheduler-based processing engine
* includes an extensible generic email composition assistant, that can turn
into a mass-mailing assistant, and is capable of interpreting
diff --git a/addons/mail/mail_message.py b/addons/mail/mail_message.py
index c76d073c12b..5fa9b8c45d7 100644
--- a/addons/mail/mail_message.py
+++ b/addons/mail/mail_message.py
@@ -306,11 +306,12 @@ class mail_message(osv.Model):
def unlink(self, cr, uid, ids, context=None):
# cascade-delete attachments that are directly attached to the message (should only happen
- # for mail.messages that act as parent for a standalone mail.mail record.
+ # for mail.messages that act as parent for a standalone mail.mail record). Also remove
+ # attachment with a void id, because this can happen with the composer.
attachments_to_delete = []
- for mail in self.browse(cr, uid, ids, context=context):
- for attach in mail.attachment_ids:
- if attach.res_model == self._name and attach.res_id == mail.id:
+ for message in self.browse(cr, uid, ids, context=context):
+ for attach in message.attachment_ids:
+ if attach.res_model == self._name and (attach.res_id == message.id or attach.res_id == 0):
attachments_to_delete.append(attach.id)
if attachments_to_delete:
self.pool.get('ir.attachment').unlink(cr, uid, attachments_to_delete, context=context)
diff --git a/addons/mail/static/src/xml/mail.xml b/addons/mail/static/src/xml/mail.xml
index 49e861ac870..161c5e2fcbc 100644
--- a/addons/mail/static/src/xml/mail.xml
+++ b/addons/mail/static/src/xml/mail.xml
@@ -81,8 +81,8 @@
<t t-call="HiddenInputFile">
<t t-set="fileupload_id" t-value="widget.fileupload_id"/>
<t t-set="fileupload_action">/web/binary/upload_attachment</t>
- <input type="hidden" name="model" t-att-value="widget.options.context.default_model"/>
- <input type="hidden" name="id" t-att-value="widget.options.context.default_res_id"/>
+ <input type="hidden" name="model" t-att-value="widget.form_view.model"/>
+ <input type="hidden" name="id" t-att-value="widget.form_view.datarecord.id || 0"/>
<input type="hidden" name="session_id" t-att-value="widget.session.session_id"/>
</t>
</t>
diff --git a/addons/mail/wizard/mail_compose_message.py b/addons/mail/wizard/mail_compose_message.py
index b62cb11aee2..a112e82b590 100644
--- a/addons/mail/wizard/mail_compose_message.py
+++ b/addons/mail/wizard/mail_compose_message.py
@@ -262,6 +262,8 @@ class mail_compose_message(osv.TransientModel):
post_values.update(email_dict)
# post the message
active_model_pool.message_post(cr, uid, [res_id], type='comment', context=context, **post_values)
+ # post process: update attachments, because id is not necessarily known when adding attachments in Chatter
+ self.pool.get('ir.attachment').write(cr, uid, [attach.id for attach in wizard.attachment_ids], {'res_id': wizard.id}, context=context)
return {'type': 'ir.actions.act_window_close'}