[IMP] mail: private message

bzr revid: chm@openerp.com-20121003142712-rkadw5oii3tt5o1u
This commit is contained in:
Christophe Matthieu
2012-10-03 16:27:12 +02:00
parent 121836232a
commit 27d3070220
4 changed files with 18 additions and 9 deletions
+9 -4
View File
@@ -151,7 +151,6 @@ class mail_message(osv.Model):
'date': lambda *a: fields.datetime.now(),
'author_id': lambda self, cr, uid, ctx={}: self._get_default_author(cr, uid, ctx),
'body': '',
'is_private': False,
}
#------------------------------------------------------
@@ -473,11 +472,9 @@ class mail_message(osv.Model):
self.pool.get('ir.attachment').unlink(cr, uid, attachments_to_delete, context=context)
return super(mail_message, self).unlink(cr, uid, ids, context=context)
def _notify(self, cr, uid, newid, context=None):
def _notify_followers(self, cr, uid, newid, message, context=None):
""" Add the related record followers to the destination partner_ids.
Call mail_notification.notify to manage the email sending
"""
message = self.browse(cr, uid, newid, context=context)
partners_to_notify = set([])
# message has no subtype_id: pure log message -> no partners, no one notified
if not message.subtype_id:
@@ -505,6 +502,14 @@ class mail_message(osv.Model):
else:
self.write(cr, SUPERUSER_ID, [newid], {'partner_ids': [(3, message.author_id.id)]}, context=context)
def _notify(self, cr, uid, newid, context=None):
""" Add the related record followers to the destination partner_ids if is not a private message.
Call mail_notification.notify to manage the email sending
"""
message = self.browse(cr, uid, newid, context=context)
if message and (message.is_private!=False and message.is_private!=None):
self._notify_followers(cr, uid, newid, message, context=context)
self.pool.get('mail.notification')._notify(cr, uid, newid, context=context)
def copy(self, cr, uid, id, default=None, context=None):
+2 -2
View File
@@ -101,14 +101,14 @@
<record id="action_mail_archives_feeds" model="ir.actions.client">
<field name="name">Archives</field>
<field name="tag">mail.wall</field>
<field name="params" eval="&quot;{'domain': [('notification_ids.partner_id.user_ids', 'in', [uid]),('unread', '=', False)]
<field name="params" eval="&quot;{'domain': [('notification_ids.partner_id.user_ids', 'in', [uid]),('unread', '=', False)],
'context': {'default_model': 'res.users', 'default_res_id': uid} }&quot;"/>
</record>
<record id="action_mail_sent_feeds" model="ir.actions.client">
<field name="name">Sent</field>
<field name="tag">mail.wall</field>
<field name="params" eval="&quot;{'domain': [('author_id.user_ids', 'in', [uid])]
<field name="params" eval="&quot;{'domain': [('author_id.user_ids', 'in', [uid])],
'context': {'default_model': 'res.users', 'default_res_id': uid} }&quot;"/>
</record>
</data>
+6 -1
View File
@@ -627,7 +627,6 @@ class mail_thread(osv.AbstractModel):
``(name,content)``, where content is NOT base64 encoded
:return: ID of newly created mail.message
"""
context = context or {}
attachments = attachments or []
assert (not thread_id) or isinstance(thread_id, (int, long)) or \
@@ -679,6 +678,12 @@ class mail_thread(osv.AbstractModel):
'attachment_ids': attachment_ids,
'subtype_id': subtype_id,
})
if parent_id:
msg = messages.browse(cr, uid, parent_id, context=context)
if msg.is_private:
values["is_private"] = msg.is_private
# Avoid warnings about non-existing fields
for x in ('from', 'to', 'cc'):
values.pop(x, None)
+1 -2
View File
@@ -121,7 +121,7 @@ class mail_compose_message(osv.TransientModel):
'partner_ids': lambda self, cr, uid, ctx={}: [],
}
def notify(self, cr, uid, newid, context=None):
def _notify(self, cr, uid, newid, context=None):
""" Override specific notify method of mail.message, because we do
not want that feature in the wizard. """
return
@@ -219,7 +219,6 @@ class mail_compose_message(osv.TransientModel):
email(s), rendering any template patterns on the fly if needed. """
if context is None:
context = {}
print '**', context
active_ids = context.get('active_ids')
for wizard in self.browse(cr, uid, ids, context=context):