[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
This commit is contained in:
Thibault Delavallée
2012-09-06 15:42:01 +02:00
parent a1fe453223
commit 9b9bdae9e0
4 changed files with 15 additions and 12 deletions
+6 -6
View File
@@ -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
+5 -4
View File
@@ -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)
+2 -2
View File
@@ -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>
@@ -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'}