From c28a29c44c638504f201a90107c7cc189c2ffda4 Mon Sep 17 00:00:00 2001 From: Christophe Matthieu Date: Wed, 3 Oct 2012 09:28:45 +0200 Subject: [PATCH 1/6] [IMP]mail: expandable py bzr revid: chm@openerp.com-20121003072845-64bufx2dj3qdpjm2 --- addons/mail/mail_message.py | 167 +++++++++++---------------------- addons/mail/tests/test_mail.py | 42 --------- 2 files changed, 55 insertions(+), 154 deletions(-) diff --git a/addons/mail/mail_message.py b/addons/mail/mail_message.py index bbf68509277..ff91a771cde 100644 --- a/addons/mail/mail_message.py +++ b/addons/mail/mail_message.py @@ -221,70 +221,64 @@ class mail_message(osv.Model): 'unread': msg.unread and msg.unread['unread'] or False } - def message_read_tree_get_expandable(self, cr, uid, parent_message, last_message, domain=[], current_level=0, level=0, context=None): - """ . """ - base_domain = [('id', '<', last_message['id'])] - if parent_message and current_level < level: - base_domain += [('parent_id', '=', parent_message['id'])] - elif parent_message: - base_domain += [('id', 'child_of', parent_message['id']), ('id', '!=', parent_message['id'])] - if domain: - base_domain += domain - extension = { 'type': 'expandable', - 'domain': base_domain, - 'thread_level': current_level, - 'context': context, - 'id': -1, - } - return extension - - def message_read_tree_flatten(self, cr, uid, parent_message, messages, domain=[], level=0, current_level=0, context=None, limit=None, add_expandable=True): - """ Given a tree with several roots of following structure : - [ {'id': 1, 'child_ids': [ - {'id': 11, 'child_ids': [...] },], - {...} ] - Flatten it to have a maximum number of levels, 0 being flat and - sort messages in a level according to a key of the messages. - Perform the flattening at leafs if above the maximum depth, then get - back in the tree. - :param context: ``sort_key``: key for sorting (id by default) - :param context: ``sort_reverse``: reverser order for sorting (True by default) + def message_read_expandable(self, cr, uid, tree, result, message_loaded, domain, context, parent_id, limit): + """ + create the expandable message for all parent message read """ - def _flatten(msg_dict): - """ from {'id': x, 'child_ids': [{child1}, {child2}]} - get [{'id': x, 'child_ids': []}, {child1}, {child2}] - """ - child_ids = msg_dict.pop('child_ids', []) - msg_dict['child_ids'] = [] - return [msg_dict] + child_ids - context = context or {} - limit = limit or self._message_read_limit + tree_not = [] + # expandable for not show message + for id_msg in tree: + # get all childs + not_loaded_ids = self.search(cr, SUPERUSER_ID, [['parent_id','=',id_msg],['id','not in',message_loaded]], None, limit=1000) + # group childs not read + id_min=None + id_max=None + nb=0 + for not_loaded_id in not_loaded_ids: + if not_loaded_id not in tree: + nb+=1 + if id_min==None or id_min>not_loaded_id: + id_min=not_loaded_id + if id_max==None or id_max0: + result.append({ + 'domain': [['id','>=',id_min],['id','<=',id_max],['parent_id','=',id_msg]], + 'nb_messages': nb, + 'type': 'expandable', + 'parent_id': id_msg, + 'id': id_min + }) + nb=0 + if nb>0: + result.append({ + 'domain': [['id','>=',id_min],['parent_id','=',id_msg]], + 'nb_messages': nb, + 'type': 'expandable', + 'parent_id': id_msg, + 'id': id_min + }) - # Depth-first flattening - for message in messages: - if message.get('type') == 'expandable': - continue - message['child_ids'] = self.message_read_tree_flatten(cr, uid, message, message['child_ids'], domain, level, current_level + 1, context=context, limit=limit) - for child in message['child_ids']: - if child.get('type') == 'expandable': - continue - message['child_nbr'] += child['child_nbr'] - # Flatten if above maximum depth - if current_level < level: - return_list = messages - else: - return_list = [flat_message for message in messages for flat_message in _flatten(message)] - # Add expandable - return_list = sorted(return_list, key=itemgetter(context.get('sort_key', 'id')), reverse=context.get('sort_reverse', True)) - if return_list and current_level == 0 and add_expandable: - expandable = self.message_read_tree_get_expandable(cr, uid, parent_message, return_list and return_list[-1] or parent_message, domain, current_level, level, context=context) - return_list.append(expandable) - elif return_list and current_level <= level and add_expandable: - expandable = self.message_read_tree_get_expandable(cr, uid, parent_message, return_list and return_list[-1] or parent_message, domain, current_level, level, context=context) - return_list.append(expandable) - return return_list + # expandable for limit max + ids = self.search(cr, SUPERUSER_ID, domain+[['id','not in',message_loaded+tree+tree_not]], context=context, limit=1) + if len(ids) > 0: + result.append( + { + 'domain': domain, + 'nb_messages': 0, + 'type': 'expandable', + 'parent_id': parent_id, + 'id': -1 + }); + + + result = sorted(result, key=lambda k: k['id']) + + return result def message_read(self, cr, uid, ids=False, domain=[], level=0, context=None, parent_id=False, limit=None): """ Read messages from mail.message, and get back a structured tree @@ -341,58 +335,7 @@ class mail_message(osv.Model): result = sorted(result, key=lambda k: k['id']) - - tree_not = [] - # expandable for not show message - for id_msg in tree: - # get all childs - not_loaded_ids = self.search(cr, SUPERUSER_ID, [['parent_id','=',id_msg],['id','not in',message_loaded]], None, limit=1000) - # group childs not read - id_min=None - id_max=None - nb=0 - for not_loaded_id in not_loaded_ids: - if not_loaded_id not in tree: - nb+=1 - if id_min==None or id_min>not_loaded_id: - id_min=not_loaded_id - if id_max==None or id_max0: - result.append({ - 'domain': [['id','>=',id_min],['id','<=',id_max],['parent_id','=',id_msg]], - 'nb_messages': nb, - 'type': 'expandable', - 'parent_id': id_msg, - 'id': id_min - }) - nb=0 - if nb>0: - result.append({ - 'domain': [['id','>=',id_min],['parent_id','=',id_msg]], - 'nb_messages': nb, - 'type': 'expandable', - 'parent_id': id_msg, - 'id': id_min - }) - - - # expandable for limit max - ids = self.search(cr, SUPERUSER_ID, domain+[['id','not in',message_loaded+tree+tree_not]], context=context, limit=1) - if len(ids) > 0: - result.append( - { - 'domain': domain, - 'nb_messages': 0, - 'type': 'expandable', - 'parent_id': parent_id, - 'id': -1 - }); - - - result = sorted(result, key=lambda k: k['id']) + result = self.message_read_expandable(cr, uid, tree, result, message_loaded, domain, context, parent_id, limit) return result diff --git a/addons/mail/tests/test_mail.py b/addons/mail/tests/test_mail.py index 7ec37d952bc..1485c40570b 100644 --- a/addons/mail/tests/test_mail.py +++ b/addons/mail/tests/test_mail.py @@ -550,48 +550,6 @@ class test_mail(TestMailMockups): # _compare_structures(struct1[x]['child_ids'], struct2[x]['child_ids'], n + 1) # # print '%send compare' % ('\t' * n) - # # ---------------------------------------- - # # CASE1: Flattening test - # # ---------------------------------------- - - # # Create dummy message structure - # import copy - # tree = [{'id': 2, 'child_nbr': 1, 'child_ids': [ - # {'id': 6, 'child_nbr': 1, 'child_ids': [ - # {'id': 8, 'child_nbr': 0, 'child_ids': []}, - # ]}, - # ]}, - # {'id': 1, 'child_nbr': 3, 'child_ids':[ - # {'id': 7, 'child_nbr': 1, 'child_ids': [ - # {'id': 9, 'child_nbr': 0, 'child_ids': []}, - # ]}, - # {'id': 4, 'child_nbr': 2, 'child_ids': [ - # {'id': 10, 'child_nbr': 0, 'child_ids': []}, - # {'id': 5, 'child_nbr': 0, 'child_ids': []}, - # ]}, - # {'id': 3, 'child_nbr': 0, 'child_ids': []}, - # ]}, - # ] - # # Test: completely flat - # new_tree = self.mail_message.message_read_tree_flatten(cr, uid, None, copy.deepcopy(tree), [('type', 'in', 'borderlands')], 0, limit=15, add_expandable=False) - # _compare_structures(new_tree, new_tree) - # self.assertEqual(len(new_tree), 10, 'message_read_tree_flatten wrong in flat') - # # Test: 1 thread level - # tree_test = [{'id': 2, 'child_ids': [ - # {'id': 8, 'child_ids': []}, {'id': 6, 'child_ids': []}, - # ]}, - # {'id': 1, 'child_ids': [ - # {'id': 10, 'child_ids': []}, {'id': 9, 'child_ids': []}, - # {'id': 7, 'child_ids': []}, {'id': 5, 'child_ids': []}, - # {'id': 4, 'child_ids': []}, {'id': 3, 'child_ids': []}, - # ]}, - # ] - # new_tree = self.mail_message.message_read_tree_flatten(cr, uid, None, copy.deepcopy(tree), [('type', 'in', 'borderlands')], 1, limit=15, add_expandable=False) - # _compare_structures(new_tree, tree_test) - # # Test: 2 thread levels - # new_tree = self.mail_message.message_read_tree_flatten(cr, uid, None, copy.deepcopy(tree), [('type', 'in', 'borderlands')], 2, limit=15, add_expandable=False) - # _compare_structures(new_tree, tree) - # # ---------------------------------------- # # CASE2: message_read test # # ---------------------------------------- From 775f0d32de0b905c0cf0a83fe0c52a757a13d14f Mon Sep 17 00:00:00 2001 From: Christophe Matthieu Date: Wed, 3 Oct 2012 10:40:29 +0200 Subject: [PATCH 2/6] [IMP]mail: domain/search bzr revid: chm@openerp.com-20121003084029-jc184upr1i1bmk4l --- addons/mail/mail_message.py | 6 ++++-- addons/mail/static/src/js/mail.js | 22 +++++++++------------- addons/mail/static/src/xml/mail.xml | 4 ++-- 3 files changed, 15 insertions(+), 17 deletions(-) diff --git a/addons/mail/mail_message.py b/addons/mail/mail_message.py index ff91a771cde..e589d8b56cb 100644 --- a/addons/mail/mail_message.py +++ b/addons/mail/mail_message.py @@ -224,6 +224,7 @@ class mail_message(osv.Model): def message_read_expandable(self, cr, uid, tree, result, message_loaded, domain, context, parent_id, limit): """ create the expandable message for all parent message read + this function is used by message_read """ tree_not = [] @@ -252,10 +253,12 @@ class mail_message(osv.Model): 'parent_id': id_msg, 'id': id_min }) + id_min=None + id_max=None nb=0 if nb>0: result.append({ - 'domain': [['id','>=',id_min],['parent_id','=',id_msg]], + 'domain': [['id','>=',id_min],['id','<=',id_max],['parent_id','=',id_msg]], 'nb_messages': nb, 'type': 'expandable', 'parent_id': id_msg, @@ -294,7 +297,6 @@ class mail_message(osv.Model): further parents :return list: list of trees of messages """ - message_loaded = context and context.get('message_loaded') or [0] # don't read the message display by .js, in context message_loaded list diff --git a/addons/mail/static/src/js/mail.js b/addons/mail/static/src/js/mail.js index e0c9ac9b7fc..462e4e2ecb8 100644 --- a/addons/mail/static/src/js/mail.js +++ b/addons/mail/static/src/js/mail.js @@ -256,10 +256,10 @@ openerp.mail = function(session) { default_res_id: 0, default_parent_id: false }, options.context || {}); - this.id = -1; + this.id = options.parameters.id || -1; this.parent_id= options.parameters.parent_id || false; this.nb_messages = options.parameters.nb_messages || 0; - this.type = options.parameters.type || false; + this.type = 'expandable'; // record options and data this.parent_thread= parent.messages!= undefined ? parent : options.options.thread._parents[0] ; @@ -501,9 +501,6 @@ openerp.mail = function(session) { } else { self.destroy(); } - for(var i in this.thread.messages){ - this.thread.messages[i].animated_destroy({fadeTime:0}); - } }, on_message_delete: function (event) { @@ -598,8 +595,8 @@ openerp.mail = function(session) { display_vote: function () { var self = this; var vote_element = session.web.qweb.render('mail.thread.message.vote', {'widget': self}); - self.$(".placeholder-mail-vote").empty(); - self.$(".placeholder-mail-vote").html(vote_element); + self.$(".placeholder-mail-vote:first").empty(); + self.$(".placeholder-mail-vote:first").html(vote_element); }, }); @@ -879,7 +876,7 @@ openerp.mail = function(session) { fetch_domain = replace_domain ? replace_domain : this.domain; fetch_context = replace_context ? replace_context : this.context; fetch_context.message_loaded= [this.id||0].concat( self.options.thread._parents[0].get_child_ids() ); - + return this.ds_message.call('message_read', [ids, fetch_domain, (this.options.thread.thread_level+1), fetch_context, this.context.default_parent_id || undefined] ).then(this.proxy('switch_new_message')); }, @@ -945,11 +942,11 @@ openerp.mail = function(session) { } } - if(parent_newer) - message.insertAfter(parent_newer.$el); - else if(parent_older) + if(parent_older) message.insertBefore(parent_older.$el); - else + else if(parent_newer) + message.insertAfter(parent_newer.$el); + else message.prependTo(thread.list_ul); return message @@ -1139,7 +1136,6 @@ openerp.mail = function(session) { message_render: function (search) { var domain = this.options.domain.concat(this.search_results['domain']); - var domain = _.extend(this.options.domain, search&&search.domain? search.domain : {}); var context = _.extend(this.options.context, search&&search.context ? search.context : {}); this.thread = new mail.Thread(this, { diff --git a/addons/mail/static/src/xml/mail.xml b/addons/mail/static/src/xml/mail.xml index 07c9b406cdc..e04a72ae664 100644 --- a/addons/mail/static/src/xml/mail.xml +++ b/addons/mail/static/src/xml/mail.xml @@ -104,7 +104,7 @@ -
  • +
    • @@ -171,7 +171,7 @@ -
    • +
    • Load more messages ( messages not display)... From d653b76e5d4d84e437cc4dc3e23e6eb4645009db Mon Sep 17 00:00:00 2001 From: Christophe Matthieu Date: Wed, 3 Oct 2012 10:51:10 +0200 Subject: [PATCH 3/6] [FIX] mail thread follower: follow/unfollow bzr revid: chm@openerp.com-20121003085110-du30higfqr9x0n26 --- addons/mail/static/src/js/mail_followers.js | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/addons/mail/static/src/js/mail_followers.js b/addons/mail/static/src/js/mail_followers.js index 953b8cd9fc8..ab6a63ea6fa 100644 --- a/addons/mail/static/src/js/mail_followers.js +++ b/addons/mail/static/src/js/mail_followers.js @@ -149,7 +149,6 @@ openerp_mail_followers = function(session, mail) { var self = this; var node_user_list = this.$('ul.oe_mail_followers_display').empty(); this.$('div.oe_mail_recthread_followers h4').html(this.options.title + (records.length>=5 ? ' (' + records.length + ')' : '') ); - console.log(records); for(var i=0; i Date: Wed, 3 Oct 2012 12:09:52 +0200 Subject: [PATCH 4/6] fixes bzr revid: chm@openerp.com-20121003100952-e5v8ncgshra3uitc --- addons/mail/mail_message.py | 6 ++++-- addons/mail/mail_message_view.xml | 9 ++++++++- addons/mail/mail_thread_view.xml | 10 ++++++++-- addons/mail/static/src/js/mail.js | 9 +++------ addons/mail/static/src/js/mail_followers.js | 5 ++--- addons/mail/static/src/xml/mail.xml | 5 ++--- 6 files changed, 27 insertions(+), 17 deletions(-) diff --git a/addons/mail/mail_message.py b/addons/mail/mail_message.py index e589d8b56cb..26d85aa68e9 100644 --- a/addons/mail/mail_message.py +++ b/addons/mail/mail_message.py @@ -134,6 +134,7 @@ class mail_message(osv.Model): 'subtype_id': fields.many2one('mail.message.subtype', 'Subtype'), 'vote_user_ids': fields.many2many('res.users', 'mail_vote', 'message_id', 'user_id', string='Votes', help='Users that voted for this message'), + 'is_private': fields.boolean('Private message'), } def _needaction_domain_get(self, cr, uid, context=None): @@ -150,6 +151,7 @@ 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, } #------------------------------------------------------ @@ -221,7 +223,7 @@ class mail_message(osv.Model): 'unread': msg.unread and msg.unread['unread'] or False } - def message_read_expandable(self, cr, uid, tree, result, message_loaded, domain, context, parent_id, limit): + def _message_read_expandable(self, cr, uid, tree, result, message_loaded, domain, context, parent_id, limit): """ create the expandable message for all parent message read this function is used by message_read @@ -337,7 +339,7 @@ class mail_message(osv.Model): result = sorted(result, key=lambda k: k['id']) - result = self.message_read_expandable(cr, uid, tree, result, message_loaded, domain, context, parent_id, limit) + result = self._message_read_expandable(cr, uid, tree, result, message_loaded, domain, context, parent_id, limit) return result diff --git a/addons/mail/mail_message_view.xml b/addons/mail/mail_message_view.xml index cc0419352af..fd0192d4496 100644 --- a/addons/mail/mail_message_view.xml +++ b/addons/mail/mail_message_view.xml @@ -87,7 +87,14 @@ Inbox mail.wall - + + + + Wall + mail.wall + diff --git a/addons/mail/mail_thread_view.xml b/addons/mail/mail_thread_view.xml index 3507e7c449f..f607238276b 100644 --- a/addons/mail/mail_thread_view.xml +++ b/addons/mail/mail_thread_view.xml @@ -18,15 +18,21 @@ + + Wall + + + + Archives - + Sent - + diff --git a/addons/mail/static/src/js/mail.js b/addons/mail/static/src/js/mail.js index 462e4e2ecb8..fbfe74768fd 100644 --- a/addons/mail/static/src/js/mail.js +++ b/addons/mail/static/src/js/mail.js @@ -1134,13 +1134,10 @@ openerp.mail = function(session) { /** Clean and display the threads */ message_render: function (search) { - var domain = this.options.domain.concat(this.search_results['domain']); - - var context = _.extend(this.options.context, search&&search.context ? search.context : {}); - + //console this.thread = new mail.Thread(this, { - 'domain' : domain, - 'context' : context, + 'domain' : this.options.domain.concat(this.search_results['domain']), + 'context' : _.extend(this.options.context, this.search_results&&this.search_results['context'] ? this.search_results['context'] : {}), 'options': { 'thread' :{ 'thread_level': this.options.thread_level, diff --git a/addons/mail/static/src/js/mail_followers.js b/addons/mail/static/src/js/mail_followers.js index 953b8cd9fc8..ab6a63ea6fa 100644 --- a/addons/mail/static/src/js/mail_followers.js +++ b/addons/mail/static/src/js/mail_followers.js @@ -149,7 +149,6 @@ openerp_mail_followers = function(session, mail) { var self = this; var node_user_list = this.$('ul.oe_mail_followers_display').empty(); this.$('div.oe_mail_recthread_followers h4').html(this.options.title + (records.length>=5 ? ' (' + records.length + ')' : '') ); - console.log(records); for(var i=0; i
    • W
    • h
    • -
    • )
    • -
    • )
    • +
    • )
    • @@ -124,7 +123,7 @@ Hide '' for this document
    • -->
    • Full reply
    • -
    • Full reply
    • +
    • Full reply by mail
    • Details
    From 121836232a9ff0b3983c6009d0470c82b16585ec Mon Sep 17 00:00:00 2001 From: Christophe Matthieu Date: Wed, 3 Oct 2012 15:03:18 +0200 Subject: [PATCH 5/6] [FIX]mail: attachment bzr revid: chm@openerp.com-20121003130318-os2ybnics3zvrsed --- addons/mail/mail_thread_view.xml | 2 +- addons/mail/static/src/css/mail.css | 2 +- addons/mail/static/src/js/mail.js | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/addons/mail/mail_thread_view.xml b/addons/mail/mail_thread_view.xml index f607238276b..4b6709dd2d8 100644 --- a/addons/mail/mail_thread_view.xml +++ b/addons/mail/mail_thread_view.xml @@ -18,7 +18,7 @@ - + Wall diff --git a/addons/mail/static/src/css/mail.css b/addons/mail/static/src/css/mail.css index 364ac7e3165..4ffb9013496 100644 --- a/addons/mail/static/src/css/mail.css +++ b/addons/mail/static/src/css/mail.css @@ -370,7 +370,7 @@ bottom: 0px; top: auto; left: auto; - right: 28px; + right: 0; height: 26px; width: 26px; min-width: 22px; diff --git a/addons/mail/static/src/js/mail.js b/addons/mail/static/src/js/mail.js index aa8b2c8a2b1..8915f1387e1 100644 --- a/addons/mail/static/src/js/mail.js +++ b/addons/mail/static/src/js/mail.js @@ -148,8 +148,8 @@ openerp.mail = function(session) { // handle attachment button this.fileupload_id = _.uniqueId('oe_fileupload'); var button_attach = this.$('button.oe_mail_compose_message_attachment'); - var rendered = session.web.qweb.render('mail.compose_message.add_attachment', {'widget': this}); - $(rendered).insertBefore(button_attach); + var rendered = $( session.web.qweb.render('mail.compose_message.add_attachment', {'widget': this}) ); + rendered.insertBefore(button_attach); // move the button inside div.oe_hidden_input_file var input_node = this.$('input[name=ufile]'); button_attach.detach().insertAfter(input_node); From 27d3070220fec3afc84d093e414fe8f72c266e7a Mon Sep 17 00:00:00 2001 From: Christophe Matthieu Date: Wed, 3 Oct 2012 16:27:12 +0200 Subject: [PATCH 6/6] [IMP] mail: private message bzr revid: chm@openerp.com-20121003142712-rkadw5oii3tt5o1u --- addons/mail/mail_message.py | 13 +++++++++---- addons/mail/mail_message_view.xml | 4 ++-- addons/mail/mail_thread.py | 7 ++++++- addons/mail/wizard/mail_compose_message.py | 3 +-- 4 files changed, 18 insertions(+), 9 deletions(-) diff --git a/addons/mail/mail_message.py b/addons/mail/mail_message.py index 26d85aa68e9..eeefd730f22 100644 --- a/addons/mail/mail_message.py +++ b/addons/mail/mail_message.py @@ -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): diff --git a/addons/mail/mail_message_view.xml b/addons/mail/mail_message_view.xml index 173b18d0ed8..6d854d4d701 100644 --- a/addons/mail/mail_message_view.xml +++ b/addons/mail/mail_message_view.xml @@ -101,14 +101,14 @@ Archives mail.wall - Sent mail.wall - diff --git a/addons/mail/mail_thread.py b/addons/mail/mail_thread.py index 9f53b4c08b1..9215b120361 100644 --- a/addons/mail/mail_thread.py +++ b/addons/mail/mail_thread.py @@ -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) diff --git a/addons/mail/wizard/mail_compose_message.py b/addons/mail/wizard/mail_compose_message.py index 3baf3ff9023..b7c51a20125 100644 --- a/addons/mail/wizard/mail_compose_message.py +++ b/addons/mail/wizard/mail_compose_message.py @@ -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):