From f19ab4383fa6dab720e59b152f5164b79e1b03bd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thibault=20Delavall=C3=A9e?= Date: Thu, 22 Mar 2012 14:01:14 +0100 Subject: [PATCH] [DOC] Added comments bzr revid: tde@openerp.com-20120322130114-3cjkzy8g9xw7qujg --- addons/mail/mail_thread.py | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/addons/mail/mail_thread.py b/addons/mail/mail_thread.py index d860ae0b9a7..ac2457c78ac 100644 --- a/addons/mail/mail_thread.py +++ b/addons/mail/mail_thread.py @@ -82,11 +82,13 @@ class mail_thread(osv.osv): #------------------------------------------------------ def create(self, cr, uid, vals, context=None): + """Automatically subscribe the creator""" thread_id = super(mail_thread, self).create(cr, uid, vals, context=context); self.message_subscribe(cr, uid, [thread_id], [uid], context=context) return thread_id; def write(self, cr, uid, ids, vals, context=None): + """Automatically subscribe the writer""" if isinstance(ids, (int, long)): ids = [ids] write_res = super(mail_thread, self).write(cr, uid, ids, vals, context=context); @@ -122,9 +124,10 @@ class mail_thread(osv.osv): def message_create(self, cr, uid, thread_id, vals, context=None): """OpenSocial: wrapper of mail.message create method - - creates the mail.message - - automatically subscribe the message writer if not already done - - push the message to subscribed users""" + - creates the mail.message + - automatically subscribe the message writer if not already done + - push the message to subscribed users + """ if context is None: context = {} user_to_push_ids = [] @@ -155,7 +158,9 @@ class mail_thread(osv.osv): return msg_id def message_parse_users(self, cr, uid, ids, string, context=None): - '''Parse message content; if find @login -(^|\s)@(\w*)-: returns the related ids''' + """Parse message content + - if find @login -(^|\s)@(\w*)-: returns the related ids + """ regex = re.compile('(^|\s)@(\w*)') login_lst = [item[1] for item in regex.findall(string)] if not login_lst: return [] @@ -179,9 +184,11 @@ class mail_thread(osv.osv): containing all the details passed as parameters. All attachments will be attached to the thread record as well as to the actual message. - If only the ``threads`` and ``subject`` parameters are provided, - a *event log* message is created, without the usual envelope - attributes (sender, recipients, etc.). + If ``email_from`` is not set or ``type`` not set as 'meail', + a note message is created, without the usual envelope + attributes (sender, recipients, etc.). + The creation of the message is done by calling ``message_create`` + method, that will manage automatic pushing of notifications. :param threads: list of thread ids, or list of browse_records representing threads to which a new message should be attached