From 8303bef9ba219c6f4d2633062486b5c611a2a578 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thibault=20Delavall=C3=A9e?= Date: Thu, 6 Sep 2012 13:14:44 +0200 Subject: [PATCH 01/24] [IMP] Chatter: added support for attachments. bzr revid: tde@openerp.com-20120906111444-n7bsjv0f10p9c3x4 --- addons/mail/mail_message.py | 2 +- addons/mail/static/src/css/mail.css | 20 +++- addons/mail/static/src/js/mail.js | 113 +++++++++++++++----- addons/mail/static/src/js/mail_followers.js | 2 +- addons/mail/static/src/xml/mail.xml | 32 +++++- 5 files changed, 135 insertions(+), 34 deletions(-) diff --git a/addons/mail/mail_message.py b/addons/mail/mail_message.py index e4862ca9fb9..dd499f6f170 100644 --- a/addons/mail/mail_message.py +++ b/addons/mail/mail_message.py @@ -147,7 +147,7 @@ class mail_message(osv.Model): def _message_dict_get(self, cr, uid, msg, context=None): """ Return a dict representation of the message browse record. """ - attachment_ids = self.pool.get('ir.attachment').name_get(cr, uid, [x.id for x in msg.attachment_ids], context=context) + attachment_ids = [{'id': attach[0], 'name': attach[1]} for attach in self.pool.get('ir.attachment').name_get(cr, uid, [x.id for x in msg.attachment_ids], context=context)] author_id = self.pool.get('res.partner').name_get(cr, uid, [msg.author_id.id], context=context)[0] author_user_id = self.pool.get('res.users').name_get(cr, uid, [msg.author_id.user_ids[0].id], context=context)[0] partner_ids = self.pool.get('res.partner').name_get(cr, uid, [x.id for x in msg.partner_ids], context=context) diff --git a/addons/mail/static/src/css/mail.css b/addons/mail/static/src/css/mail.css index 240627c9e6c..34b090cde61 100644 --- a/addons/mail/static/src/css/mail.css +++ b/addons/mail/static/src/css/mail.css @@ -307,6 +307,22 @@ padding: 1px; } +/* attachment button: override of openerp values */ +.openerp .oe_mail_msg_content .oe_mail_compose_message_icons div.oe_hidden_input_file { + display: inline-block; + width: 24px; + height: 24px; +} +.openerp .oe_mail_msg_content .oe_mail_compose_message_icons input.oe_form_binary_file { + bottom: 0px; + top: auto; + left: auto; + right: 24px; + height: 24px; + width: 24px; + min-width: 24px; +} + /* ------------------------------------------------------------ */ /* Messages layout /* ------------------------------------------------------------ */ @@ -376,7 +392,7 @@ } /* Attachments list */ -.openerp ul.oe_mail_msg_attachments { +.openerp .oe_mail_msg_content ul.oe_mail_msg_attachments { display: none; width: 100%; border-top: 1px solid #CCC; @@ -384,7 +400,7 @@ padding: .5em 0; list-style-position: inside; } -.openerp ul.oe_mail_msg_attachments li { +.openerp .oe_mail_msg_content ul.oe_mail_msg_attachments li { float: none; margin: 0; padding: 0; diff --git a/addons/mail/static/src/js/mail.js b/addons/mail/static/src/js/mail.js index a5a64a59a8b..1f2d9fda6a6 100644 --- a/addons/mail/static/src/js/mail.js +++ b/addons/mail/static/src/js/mail.js @@ -37,6 +37,27 @@ openerp.mail = function(session) { }, }); + /** + * ------------------------------------------------------------ + * Sidebar + * ------------------------------------------------------------ + * + * Override of sidebar do_attachment_new method, to catch attachments added + * through the sidebar and show them in the Chatter composition form. + */ + + // session.web.Sidebar = session.web.Sidebar.extend({ + // do_attachment_new: function(attachment) { + // this._super(attachment); + // var message_ids = this.getParent().fields.message_ids || undefined; + // if (! message_ids) { return; } + // var compose_message_widget = message_ids.thread.compose_message_widget; + // if (! compose_message_widget) { return; } + // compose_message_widget.attachments.push(attachment); + // compose_message_widget.display_attachments(); + // }, + // }); + /** * ------------------------------------------------------------ * ChatterUtils @@ -60,12 +81,17 @@ openerp.mail = function(session) { mail.ChatterUtils = { - /** get an image in /web/binary/image?... */ - get_image: function(session_prefix, session_id, model, field, id) { - return session_prefix + '/web/binary/image?session_id=' + session_id + '&model=' + model + '&field=' + field + '&id=' + (id || ''); + /** Get an image in /web/binary/image?... */ + get_image: function(session, model, field, id) { + return session.prefix + '/web/binary/image?session_id=' + session.session_id + '&model=' + model + '&field=' + field + '&id=' + (id || ''); }, - /** check if the current user is the message author */ + /** Get the url of an attachment {'id': id} */ + get_attachment_url: function (session, attachment) { + return session.origin + '/web/binary/saveas?session_id=' + session.session_id + '&model=ir.attachment&field=datas&filename_field=datas_fname&id=' + attachment['id']; + }, + + /** Check if the current user is the message author */ is_author: function (widget, message_user_id) { return (widget.session && widget.session.uid != 0 && widget.session.uid == message_user_id); }, @@ -111,21 +137,22 @@ openerp.mail = function(session) { init: function (parent, options) { var self = this; this._super(parent); + this.attachment_ids = []; // options this.options = options || {}; this.options.context = options.context || {}; this.options.form_xml_id = options.form_xml_id || 'email_compose_message_wizard_form_chatter'; this.options.form_view_id = options.form_view_id || false; // debug - // console.groupCollapsed('New ComposeMessage: model', this.options.context.default_res_model, ', id', this.options.context.default_res_id); - // console.log('context:', this.options.context); - // console.groupEnd(); + console.groupCollapsed('New ComposeMessage: model', this.options.context.default_model, ', id', this.options.context.default_res_id); + console.log('context:', this.options.context); + console.groupEnd(); }, start: function () { this._super.apply(this, arguments); // customize display: add avatar, clean previous content - var user_avatar = mail.ChatterUtils.get_image(this.session.prefix, this.session.session_id, 'res.users', 'image_small', this.session.uid); + var user_avatar = mail.ChatterUtils.get_image(this.session, 'res.users', 'image_small', this.session.uid); this.$el.find('img.oe_mail_icon').attr('src', user_avatar); this.$el.find('div.oe_mail_msg_content').empty(); // create a context for the dataset and default_get of the wizard @@ -156,10 +183,42 @@ openerp.mail = function(session) { }); // add the form, bind events, activate the form var msg_node = this.$el.find('div.oe_mail_msg_content'); - return $.when(this.form_view.appendTo(msg_node)).pipe(function() { - self.bind_events(); - self.form_view.do_show(); - }); + return $.when(this.form_view.appendTo(msg_node)).pipe(this.proxy('postprocess_create_form_view')); + }, + + postprocess_create_form_view: function () { + // handle attachment button + this.fileupload_id = _.uniqueId('oe_fileupload'); + var button_attach = this.$el.find('button.oe_mail_compose_message_attachment'); + 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.$el.find('input[name=ufile]'); + button_attach.detach().insertAfter(input_node); + // set the function called when attachments are added + this.$el.find('input.oe_form_binary_file').change(this.on_attachment_changed); + this.bind_events(); + this.form_view.do_show(); + }, + + /** Called when the user submits a new attachment */ + on_attachment_changed: function(e) { + var $e = $(e.target); + if ($e.val() !== '') { + this.$el.find('form.oe_form_binary_form').submit(); + session.web.blockUI(); + } + }, + + display_attachments: function () { + var attach_node = this.$el.find('div.oe_mail_compose_message_attachments'); + var rendered = session.web.qweb.render('mail.thread.message.attachments', {'record': this}); + attach_node.empty(); + $(rendered).appendTo(attach_node); + this.$el.find('.oe_mail_msg_attachments').show(); + var composer_attachment_ids = _.pluck(this.attachment_ids, 'id'); + var onchange_like = {'value': {'attachment_ids': composer_attachment_ids}} + this.form_view.on_processed_onchange(onchange_like, []); }, /** @@ -170,6 +229,7 @@ openerp.mail = function(session) { refresh: function (new_context) { if (! this.form_view) return; var self = this; + this.attachments = []; this.options.context = _.extend(this.options.context, new_context || {}); this.ds_compose.context = _.extend(this.ds_compose.context, this.options.context); return this.ds_compose.call('default_get', [ @@ -184,11 +244,19 @@ openerp.mail = function(session) { * in the function. */ bind_events: function() { var self = this; - // event: click on 'Attachment' icon-link that opens the dialog to - // add an attachment. + // event: click on 'Attachment' button that opens the dialog to add an attachment. this.$el.on('click', 'button.oe_mail_compose_message_attachment', function (event) { event.stopImmediatePropagation(); }); + // event: add a new attachment + $(window).on(this.fileupload_id, function() { + var args = [].slice.call(arguments).slice(1); + var attachment = args[0]; + attachment['url'] = mail.ChatterUtils.get_attachment_url(self.session, attachment); + self.attachment_ids.push(attachment); + self.display_attachments(); + session.web.unblockUI(); + }); }, }), @@ -407,7 +475,6 @@ openerp.mail = function(session) { } else { self.display_record(record); - // if (self.options.thread_level >= 0) { self.thread = new mail.Thread(self, { 'context': { 'default_model': record.model, @@ -419,7 +486,6 @@ openerp.mail = function(session) { }); self.$el.find('li.oe_mail_thread_msg:last').append('
'); self.thread.appendTo(self.$el.find('div.oe_mail_thread_subthread:last')); - // } } }); if (! _expendable) { @@ -431,7 +497,7 @@ openerp.mail = function(session) { * - record.date: formatting according to the user timezone * - record.timerelative: relative time givein by timeago lib * - record.avatar: image url - * - record.attachments[].url: url of each attachment + * - record.attachment_ids[].url: url of each attachment * - record.is_author: is the current user the author of the record */ display_record: function (record) { // formatting and additional fields @@ -440,14 +506,11 @@ openerp.mail = function(session) { if (record.type == 'email') { record.avatar = ('/mail/static/src/img/email_icon.png'); } else { - record.avatar = mail.ChatterUtils.get_image(this.session.prefix, this.session.session_id, 'res.partner', 'image_small', record.author_id[0]); + record.avatar = mail.ChatterUtils.get_image(this.session, 'res.partner', 'image_small', record.author_id[0]); } - //TDE: FIX - if (record.attachments) { - for (var l in record.attachments) { - var url = self.session.origin + '/web/binary/saveas?session_id=' + self.session.session_id + '&model=ir.attachment&field=datas&filename_field=datas_fname&id='+records[k].attachments[l].id; - record.attachments[l].url = url; - } + for (var l in record.attachment_ids) { + var attach = record.attachment_ids[l]; + attach['url'] = mail.ChatterUtils.get_attachment_url(this.session, attach); } record.is_author = mail.ChatterUtils.is_author(this, record.author_user_id[0]); // render, add the expand feature @@ -473,7 +536,7 @@ openerp.mail = function(session) { }, display_user_avatar: function () { - var avatar = mail.ChatterUtils.get_image(this.session.prefix, this.session.session_id, 'res.users', 'image_small', this.options.uid); + var avatar = mail.ChatterUtils.get_image(this.session, 'res.users', 'image_small', this.session.uid); return this.$el.find('img.oe_mail_icon').attr('src', avatar); }, diff --git a/addons/mail/static/src/js/mail_followers.js b/addons/mail/static/src/js/mail_followers.js index e5d216ed3d2..34976269285 100644 --- a/addons/mail/static/src/js/mail_followers.js +++ b/addons/mail/static/src/js/mail_followers.js @@ -79,7 +79,7 @@ openerp_mail_followers = function(session, mail) { var node_user_list = this.$el.find('ul.oe_mail_followers_display').empty(); this.$el.find('div.oe_mail_recthread_followers h4').html(this.options.title + ' (' + records.length + ')'); _(records).each(function (record) { - record.avatar_url = mail.ChatterUtils.get_image(self.session.prefix, self.session.session_id, 'res.partner', 'image_small', record.id); + record.avatar_url = mail.ChatterUtils.get_image(self.session, 'res.partner', 'image_small', record.id); $(session.web.qweb.render('mail.followers.partner', {'record': record})).appendTo(node_user_list); }); if (this.message_is_follower) { diff --git a/addons/mail/static/src/xml/mail.xml b/addons/mail/static/src/xml/mail.xml index f6be765c603..49e861ac870 100644 --- a/addons/mail/static/src/xml/mail.xml +++ b/addons/mail/static/src/xml/mail.xml @@ -73,6 +73,20 @@
+ + + + + /web/binary/upload_attachment + + + + + + + +
    + +
  • +
    +
+
+ From e34fcc076cdcda1ed6da1cd6ba6aa567eeb0d0c1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thibault=20Delavall=C3=A9e?= Date: Thu, 6 Sep 2012 14:20:46 +0200 Subject: [PATCH 02/24] [FIX] mail.js: fixed wrong res_id passed into subthreads; fixed message_post using a wrong dataset; fixed message_post calling message_fetch after posting with a proxy that gave default values, use a then without args instead. bzr revid: tde@openerp.com-20120906122046-g8vqkqlbb2ymb6ad --- addons/mail/static/src/js/mail.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/addons/mail/static/src/js/mail.js b/addons/mail/static/src/js/mail.js index 1f2d9fda6a6..94ce41802cc 100644 --- a/addons/mail/static/src/js/mail.js +++ b/addons/mail/static/src/js/mail.js @@ -478,7 +478,7 @@ openerp.mail = function(session) { self.thread = new mail.Thread(self, { 'context': { 'default_model': record.model, - 'default_id': record.res_id, + 'default_res_id': record.res_id, 'default_parent_id': record.id }, 'message_data': record.child_ids, 'thread_level': self.options.thread_level-1, 'show_header_compose': false, 'show_reply': self.options.thread_level > 1, @@ -547,9 +547,9 @@ openerp.mail = function(session) { var body = comment_node.val(); comment_node.val(''); } - return this.ds_post.call('message_post', [ - [this.options.context.res_id], body, false, 'comment', this.options.context.parent_id] - ).then(this.proxy('message_fetch')); + return this.ds_thread.call('message_post', [ + [this.options.context.default_res_id], body, false, 'comment', this.options.context.default_parent_id, undefined] + ).then(self.message_fetch()); }, /** Action: 'shows more' to fetch new messages */ From a1fe4532239a343054e0d3a05df94dd68f7ac359 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thibault=20Delavall=C3=A9e?= Date: Thu, 6 Sep 2012 14:52:17 +0200 Subject: [PATCH 03/24] [IMP] mail_message: attachments deleted when unlinking are those with model=self._name, not only 'mail.mesage'. This allows to remove the unlink override in mail.compose.message. bzr revid: tde@openerp.com-20120906125217-27nlyveznh12bk63 --- addons/mail/mail_message.py | 4 ++-- addons/mail/wizard/mail_compose_message.py | 6 ------ 2 files changed, 2 insertions(+), 8 deletions(-) diff --git a/addons/mail/mail_message.py b/addons/mail/mail_message.py index dd499f6f170..c76d073c12b 100644 --- a/addons/mail/mail_message.py +++ b/addons/mail/mail_message.py @@ -310,11 +310,11 @@ class mail_message(osv.Model): attachments_to_delete = [] for mail in self.browse(cr, uid, ids, context=context): for attach in mail.attachment_ids: - if attach.res_model == 'mail.message' and attach.res_id == mail.id: + if attach.res_model == self._name and attach.res_id == mail.id: attachments_to_delete.append(attach.id) if attachments_to_delete: self.pool.get('ir.attachment').unlink(cr, uid, attachments_to_delete, context=context) - return super(mail_message,self).unlink(cr, uid, ids, context=context) + return super(mail_message, self).unlink(cr, uid, ids, context=context) def notify(self, cr, uid, newid, context=None): """ Add the related record followers to the destination partner_ids. diff --git a/addons/mail/wizard/mail_compose_message.py b/addons/mail/wizard/mail_compose_message.py index 3153ccc2069..b62cb11aee2 100644 --- a/addons/mail/wizard/mail_compose_message.py +++ b/addons/mail/wizard/mail_compose_message.py @@ -221,12 +221,6 @@ class mail_compose_message(osv.TransientModel): res.update(self._verify_partner_email(cr, uid, value[0][2], context=context)) return res - def unlink(self, cr, uid, ids, context=None): - # Cascade delete all attachments, as they are owned by the composition wizard - for wizard in self.read(cr, uid, ids, ['attachment_ids'], context=context): - self.pool.get('ir.attachment').unlink(cr, uid, wizard['attachment_ids'], context=context) - return super(mail_compose_message, self).unlink(cr, uid, ids, context=context) - def dummy(self, cr, uid, ids, context=None): """ TDE: defined to have buttons that do basically nothing. It is currently impossible to have buttons that do nothing special From 9b9bdae9e008e930eaf1cf208b90f66bdbdf4e7d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thibault=20Delavall=C3=A9e?= Date: Thu, 6 Sep 2012 15:42:01 +0200 Subject: [PATCH 04/24] [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 --- addons/mail/__openerp__.py | 12 ++++++------ addons/mail/mail_message.py | 9 +++++---- addons/mail/static/src/xml/mail.xml | 4 ++-- addons/mail/wizard/mail_compose_message.py | 2 ++ 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 @@ /web/binary/upload_attachment - - + + 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'} From b6eeb581aca218f61d2242929906e25b6ca44cf7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thibault=20Delavall=C3=A9e?= Date: Thu, 6 Sep 2012 15:46:52 +0200 Subject: [PATCH 05/24] [REM] mail.css: removed dead css specifications. bzr revid: tde@openerp.com-20120906134652-qc0br6b4kyxq5bdw --- addons/mail/static/src/css/mail.css | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/addons/mail/static/src/css/mail.css b/addons/mail/static/src/css/mail.css index 34b090cde61..bf272a9fe96 100644 --- a/addons/mail/static/src/css/mail.css +++ b/addons/mail/static/src/css/mail.css @@ -338,11 +338,7 @@ text-decoration: none; } -.openerp .oe_mail_msg_subtitle { - margin: 0 0 .5em 0; -} -.openerp .oe_mail_msg_footer, -.openerp .oe_mail_msg_subtitle { +.openerp .oe_mail_msg_footer { color: #888; } @@ -356,12 +352,12 @@ text-align: justify; } -.openerp .oe_mail_msg_body span.oe_mail_msg_tail { - display: inline; +.openerp .oe_mail_msg_body pre { + font-family: "Lucida Grande", Helvetica, Verdana, Arial, sans-serif; } -.openerp .oe_mail_oe_bold { - font-weight: bold; +.openerp .oe_mail_msg_body span.oe_mail_msg_tail { + display: inline; } /* Read more/less link */ From 07663470e5dda3ef0c61912590286fa6992f8aab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thibault=20Delavall=C3=A9e?= Date: Thu, 6 Sep 2012 16:01:31 +0200 Subject: [PATCH 06/24] [FIX] mail.css: messages in 'pre' now use the OpenERP fonts, without margins. bzr revid: tde@openerp.com-20120906140131-72xxfox3c5ctm4pa --- addons/mail/static/src/css/mail.css | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/addons/mail/static/src/css/mail.css b/addons/mail/static/src/css/mail.css index bf272a9fe96..8685ef88d81 100644 --- a/addons/mail/static/src/css/mail.css +++ b/addons/mail/static/src/css/mail.css @@ -352,8 +352,9 @@ text-align: justify; } -.openerp .oe_mail_msg_body pre { +.openerp .oe_mail_msg_record_body pre { font-family: "Lucida Grande", Helvetica, Verdana, Arial, sans-serif; + margin: 0px; } .openerp .oe_mail_msg_body span.oe_mail_msg_tail { From 910bc5f00a5ad4838cc3c2693dfd097134921a2f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thibault=20Delavall=C3=A9e?= Date: Fri, 7 Sep 2012 13:54:22 +0200 Subject: [PATCH 07/24] [REV] Reverted hack about attachments, that was not good. bzr revid: tde@openerp.com-20120907115422-zfynv8pdsxk5p3vg --- addons/mail/mail_message.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/addons/mail/mail_message.py b/addons/mail/mail_message.py index 5fa9b8c45d7..18a88bb0b61 100644 --- a/addons/mail/mail_message.py +++ b/addons/mail/mail_message.py @@ -306,12 +306,11 @@ 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). Also remove - # attachment with a void id, because this can happen with the composer. + # for mail.messages that act as parent for a standalone mail.mail record). attachments_to_delete = [] 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): + if attach.res_model == self._name and attach.res_id == message.id: attachments_to_delete.append(attach.id) if attachments_to_delete: self.pool.get('ir.attachment').unlink(cr, uid, attachments_to_delete, context=context) From 57f2b2f90960d2883155fdba413d665858d27c8e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thibault=20Delavall=C3=A9e?= Date: Tue, 11 Sep 2012 14:11:07 +0200 Subject: [PATCH 08/24] [FIX] Fixed conflict that I has not seen. bzr revid: tde@openerp.com-20120911121107-surc6mwhfldsa541 --- addons/mail/static/src/js/mail.js | 4 ---- 1 file changed, 4 deletions(-) diff --git a/addons/mail/static/src/js/mail.js b/addons/mail/static/src/js/mail.js index 5d80232bc2b..c02b81d0c4f 100644 --- a/addons/mail/static/src/js/mail.js +++ b/addons/mail/static/src/js/mail.js @@ -536,11 +536,7 @@ openerp.mail = function(session) { }, display_user_avatar: function () { -<<<<<<< TREE var avatar = mail.ChatterUtils.get_image(this.session, 'res.users', 'image_small', this.session.uid); -======= - var avatar = mail.ChatterUtils.get_image(this.session.prefix, this.session.session_id, 'res.users', 'image_small', this.session.uid); ->>>>>>> MERGE-SOURCE return this.$el.find('img.oe_mail_icon').attr('src', avatar); }, From 52a2174a5d6406a2b74b23782e4e193fd34a00a5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thibault=20Delavall=C3=A9e?= Date: Tue, 11 Sep 2012 14:50:19 +0200 Subject: [PATCH 09/24] [FIX] Chatter: fixed CSS issues with attachments. bzr revid: tde@openerp.com-20120911125019-9gdi4cjp6iefw5vz --- addons/mail/static/src/css/mail.css | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/addons/mail/static/src/css/mail.css b/addons/mail/static/src/css/mail.css index 8685ef88d81..9aa7bd1dfe3 100644 --- a/addons/mail/static/src/css/mail.css +++ b/addons/mail/static/src/css/mail.css @@ -312,15 +312,22 @@ display: inline-block; width: 24px; height: 24px; + margin: 2px; +} +.openerp .oe_mail_msg_content .oe_mail_compose_message_icons div.oe_hidden_input_file button { + margin: 0px; } .openerp .oe_mail_msg_content .oe_mail_compose_message_icons input.oe_form_binary_file { bottom: 0px; top: auto; left: auto; - right: 24px; - height: 24px; - width: 24px; - min-width: 24px; + right: 28px; + height: 26px; + width: 26px; + min-width: 22px; + font-size: 0px; + margin: 0px; + padding: 0px; } /* ------------------------------------------------------------ */ From b82a3a2223c2c081b325902067dd2e9e8dbd032c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thibault=20Delavall=C3=A9e?= Date: Tue, 11 Sep 2012 15:21:22 +0200 Subject: [PATCH 10/24] [FIX] Wall: fixed search not taken into account in the domain given to the displayed threads. bzr revid: tde@openerp.com-20120911132122-9w5d1jdk0br5khqs --- addons/mail/static/src/js/mail.js | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/addons/mail/static/src/js/mail.js b/addons/mail/static/src/js/mail.js index a4be9456ab3..5a611de0a27 100644 --- a/addons/mail/static/src/js/mail.js +++ b/addons/mail/static/src/js/mail.js @@ -684,11 +684,8 @@ openerp.mail = function(session) { this.options.domain = options.domain || []; this.options.context = options.context || {}; this.options.thread_level = options.thread_level || 1; - this.thread_list = []; - this.ds_msg = new session.web.DataSetSearch(this, 'mail.message'); - // for search view - this.search = {'domain': [], 'context': {}, 'groupby': {}} this.search_results = {'domain': [], 'context': {}, 'groupby': {}} + this.ds_msg = new session.web.DataSetSearch(this, 'mail.message'); }, start: function () { @@ -699,7 +696,7 @@ openerp.mail = function(session) { }, destroy: function () { - for (var i in this.thread_list) { this.thread_list[i].destroy(); } + if (this.thread) this.thread.destroy(); this._super.apply(this, arguments); }, @@ -746,10 +743,11 @@ openerp.mail = function(session) { /** Display the Wall threads */ message_display: function () { + var thread_domain = this.options.domain.concat(this.search_results['domain']); var render_res = session.web.qweb.render('mail.wall_thread_container', {}); $('
  • ').html(render_res).appendTo(this.$el.find('ul.oe_mail_wall_threads')); var thread = new mail.Thread(this, { - 'domain': this.options.domain, 'context': this.options.context, + 'domain': thread_domain, 'context': this.options.context, 'thread_level': this.options.thread_level, 'composer': true, // display options 'show_header_compose': true, 'show_reply': this.options.thread_level > 0, @@ -757,7 +755,7 @@ openerp.mail = function(session) { } ); thread.appendTo(this.$el.find('li.oe_mail_wall_thread:last')); - this.thread_list.push(thread); + this.thread = thread; }, }); }; From 9c50df8f3160277b5e0615ccce7f2c1292beb5bf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thibault=20Delavall=C3=A9e?= Date: Tue, 11 Sep 2012 15:22:45 +0200 Subject: [PATCH 11/24] [CLEAN] small cleanup of test_mail. bzr revid: tde@openerp.com-20120911132245-35ik5ny86b2122zl --- addons/mail/tests/test_mail.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/addons/mail/tests/test_mail.py b/addons/mail/tests/test_mail.py index f45745f31dc..20eb2ad9b91 100644 --- a/addons/mail/tests/test_mail.py +++ b/addons/mail/tests/test_mail.py @@ -29,7 +29,7 @@ Received: by mail1.openerp.com (Postfix, from userid 10002) From: Sylvie Lelitre Subject: {subject} MIME-Version: 1.0 -Content-Type: multipart/alternative; +Content-Type: multipart/alternative; boundary="----=_Part_4200734_24778174.1344608186754" Date: Fri, 10 Aug 2012 14:16:26 +0000 Message-ID: <1198923581.41972151344608186760.JavaMail@agrolait.com> @@ -52,9 +52,9 @@ Content-Transfer-Encoding: quoted-printable =20 =20 - +

    Please call me as soon as possible this afternoon!

    - +

    --
    Sylvie

    @@ -153,7 +153,7 @@ class test_mail(common.TransactionCase): test_msg_id = '' mail_text = MAIL_TEMPLATE_PLAINTEXT.format(to='groups@example.com', subject='frogs', extra='', msg_id=test_msg_id) self.mail_thread.message_process(cr, uid, None, mail_text) - new_mail = self.mail_message.browse(cr, uid, self.mail_message.search(cr, uid, [('message_id','=',test_msg_id)])[0]) + new_mail = self.mail_message.browse(cr, uid, self.mail_message.search(cr, uid, [('message_id', '=', test_msg_id)])[0]) self.assertEqual(new_mail.body, '\n

    \nPlease call me as soon as possible this afternoon!\n\n--\nSylvie\n
    \n', 'plaintext mail incorrectly parsed') @@ -458,6 +458,7 @@ class test_mail(common.TransactionCase): # It will be updated as soon as we have fixed specs ! cr, uid = self.cr, self.uid group_pigs = self.mail_group.browse(cr, uid, self.group_pigs_id) + def _compare_structures(struct1, struct2, n=0): # print '%scompare structure' % ('\t' * n) self.assertEqual(len(struct1), len(struct2), 'message_read structure number of childs incorrect') From 75488f0408199da530ffe06af27c0895409ebe86 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thibault=20Delavall=C3=A9e?= Date: Tue, 11 Sep 2012 15:37:06 +0200 Subject: [PATCH 12/24] [CLEAN] mail.js: small cleaning. bzr revid: tde@openerp.com-20120911133706-lhmy7s75b8eappra --- addons/mail/static/src/js/mail.js | 63 ++++++------------------------- 1 file changed, 11 insertions(+), 52 deletions(-) diff --git a/addons/mail/static/src/js/mail.js b/addons/mail/static/src/js/mail.js index 5a611de0a27..9a8de1480de 100644 --- a/addons/mail/static/src/js/mail.js +++ b/addons/mail/static/src/js/mail.js @@ -20,10 +20,8 @@ openerp.mail = function(session) { do_action: function(action, on_close) { if (action.res_model == 'mail.compose.message' && action.context && action.context.redirect == true && - this.fields && this.fields.message_ids && - this.fields.message_ids.view.get("actual_mode") != 'create') { - var record_thread = this.fields.message_ids; - var thread = record_thread.thread; + this.fields && this.fields.message_ids && this.fields.message_ids.view.get("actual_mode") != 'create') { + var thread = this.fields.message_ids.thread; thread.refresh_composition_form(action.context); return true; } @@ -33,46 +31,17 @@ openerp.mail = function(session) { }, }); - /** - * ------------------------------------------------------------ - * Sidebar - * ------------------------------------------------------------ - * - * Override of sidebar do_attachment_new method, to catch attachments added - * through the sidebar and show them in the Chatter composition form. - */ - - // session.web.Sidebar = session.web.Sidebar.extend({ - // do_attachment_new: function(attachment) { - // this._super(attachment); - // var message_ids = this.getParent().fields.message_ids || undefined; - // if (! message_ids) { return; } - // var compose_message_widget = message_ids.thread.compose_message_widget; - // if (! compose_message_widget) { return; } - // compose_message_widget.attachments.push(attachment); - // compose_message_widget.display_attachments(); - // }, - // }); /** * ------------------------------------------------------------ * ChatterUtils * ------------------------------------------------------------ * - * This class holds a few tools method that will be used by - * the various Chatter widgets. - * + * This class holds a few tools method for Chatter. * Some regular expressions not used anymore, kept because I want to * - (^|\s)@((\w|@|\.)*): @login@log.log - * 1. '(void)' - * 2. login@log.log * - (^|\s)\[(\w+).(\w+),(\d)\|*((\w|[@ .,])*)\]: [ir.attachment,3|My Label], * for internal links - * 1. '(void)' - * 2. 'ir' - * 3. 'attachment' - * 4. '3' - * 5. 'My Label' */ mail.ChatterUtils = { @@ -139,10 +108,6 @@ openerp.mail = function(session) { this.options.context = options.context || {}; this.options.form_xml_id = options.form_xml_id || 'email_compose_message_wizard_form_chatter'; this.options.form_view_id = options.form_view_id || false; - // debug - console.groupCollapsed('New ComposeMessage: model', this.options.context.default_model, ', id', this.options.context.default_res_id); - console.log('context:', this.options.context); - console.groupEnd(); }, start: function () { @@ -597,13 +562,11 @@ openerp.mail = function(session) { * mail_thread Widget * ------------------------------------------------------------ * - * This widget handles the display of the Chatter on documents. + * This widget handles the display of messages on a document. Its main + * use is to receive a context and a domain, and to delegate the message + * fetching and displaying to the Thread widget. */ - - /* Add mail_thread widget to registry */ session.web.form.widgets.add('mail_thread', 'openerp.mail.RecordThread'); - - /** mail_thread widget: thread of comments */ mail.RecordThread = session.web.form.AbstractField.extend({ template: 'mail.record_thread', @@ -616,8 +579,7 @@ openerp.mail = function(session) { start: function() { this._super.apply(this, arguments); - // NB: all the widget should be modified to check the actual_mode property on view, not use - // any other method to know if the view is in create mode anymore + // NB: check the actual_mode property on view to know if the view is in create mode anymore this.view.on("change:actual_mode", this, this._check_visibility); this._check_visibility(); }, @@ -646,9 +608,8 @@ openerp.mail = function(session) { this.$el.find('div.oe_mail_recthread_main').empty(); if (this.thread) { this.thread.destroy(); } var thread = new mail.Thread(self, { - 'context': this.options.context, + 'context': this.options.context, 'message_ids': this.get_value(), 'thread_level': this.options.thread_level, 'show_header_compose': true, - 'message_ids': this.get_value(), 'show_delete': true, 'composer': true }); this.thread = thread; return thread.appendTo(this.$el.find('div.oe_mail_recthread_main')); @@ -661,13 +622,11 @@ openerp.mail = function(session) { * Wall Widget * ------------------------------------------------------------ * - * This widget handles the display of the Chatter on the Wall. + * This widget handles the display of messages on a Wall. Its main + * use is to receive a context and a domain, and to delegate the message + * fetching and displaying to the Thread widget. */ - - /* Add WallView widget to registry */ session.web.client_actions.add('mail.wall', 'session.mail.Wall'); - - /* WallView widget: a wall of messages */ mail.Wall = session.web.Widget.extend({ template: 'mail.wall', From cd4c6756bfd4f0d11596d6e15974b4c49ed3d823 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thibault=20Delavall=C3=A9e?= Date: Tue, 11 Sep 2012 15:44:55 +0200 Subject: [PATCH 13/24] [REM] mail.group: removed max-width. bzr revid: tde@openerp.com-20120911134455-18kythu9ynjwe2iv --- addons/mail/static/src/css/mail_group.css | 1 - 1 file changed, 1 deletion(-) diff --git a/addons/mail/static/src/css/mail_group.css b/addons/mail/static/src/css/mail_group.css index 8f4ca61d531..b700cb8c80f 100644 --- a/addons/mail/static/src/css/mail_group.css +++ b/addons/mail/static/src/css/mail_group.css @@ -12,7 +12,6 @@ min-height: 0px; max-height: none; padding: 0px 18px; - max-width: 80%; } /* Resize footer width */ From f0a792c565c5e2ebf886da4c9440956efb235c84 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thibault=20Delavall=C3=A9e?= Date: Tue, 11 Sep 2012 16:16:50 +0200 Subject: [PATCH 14/24] [FIX] purchase, account: updated call to mail.compose.message form view, using default values for the form. bzr revid: tde@openerp.com-20120911141650-krnq836afvwmpln2 --- addons/account/account_invoice.py | 27 ++++++++++++++++----------- addons/purchase/purchase.py | 11 ++++++++--- 2 files changed, 24 insertions(+), 14 deletions(-) diff --git a/addons/account/account_invoice.py b/addons/account/account_invoice.py index 42d42e7ec1b..ef2ffc5cdbe 100644 --- a/addons/account/account_invoice.py +++ b/addons/account/account_invoice.py @@ -395,18 +395,23 @@ class account_invoice(osv.osv): template_id = template and template[1] or False res = mod_obj.get_object_reference(cr, uid, 'mail', 'email_compose_message_wizard_form') res_id = res and res[1] or False - ctx = dict(context, active_model='account.invoice', active_id=ids[0]) - ctx.update({'mail.compose.template_id': template_id}) + ctx = dict(context) + ctx.update({ + 'default_model': 'account.invoice', + 'default_res_id': ids[0], + 'default_use_template': True, + 'default_template_id': template_id, + }) return { - 'view_type': 'form', - 'view_mode': 'form', - 'res_model': 'mail.compose.message', - 'views': [(res_id, 'form')], - 'view_id': res_id, - 'type': 'ir.actions.act_window', - 'target': 'new', - 'context': ctx, - 'nodestroy': True, + 'view_type': 'form', + 'view_mode': 'form', + 'res_model': 'mail.compose.message', + 'views': [(res_id, 'form')], + 'view_id': res_id, + 'type': 'ir.actions.act_window', + 'target': 'new', + 'context': ctx, + 'nodestroy': True, } def confirm_paid(self, cr, uid, ids, context=None): diff --git a/addons/purchase/purchase.py b/addons/purchase/purchase.py index 592bf783a64..1f6279af3ad 100644 --- a/addons/purchase/purchase.py +++ b/addons/purchase/purchase.py @@ -347,13 +347,18 @@ class purchase_order(osv.osv): template_id = template and template[1] or False res = mod_obj.get_object_reference(cr, uid, 'mail', 'email_compose_message_wizard_form') res_id = res and res[1] or False - ctx = dict(context, active_model='purchase.order', active_id=ids[0]) - ctx.update({'mail.compose.template_id': template_id}) + ctx = dict(context) + ctx.update({ + 'default_model': 'purchase.order', + 'default_res_id': ids[0], + 'default_use_template': True, + 'default_template_id': template_id, + }) return { 'view_type': 'form', 'view_mode': 'form', 'res_model': 'mail.compose.message', - 'views': [(res_id,'form')], + 'views': [(res_id, 'form')], 'view_id': res_id, 'type': 'ir.actions.act_window', 'target': 'new', From 0ef0b3df61b32e621bd5e0c07c735378417543e1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thibault=20Delavall=C3=A9e?= Date: Tue, 11 Sep 2012 16:17:40 +0200 Subject: [PATCH 15/24] [FIX] Chatter: fixed reloading when posting a message; added domain for record threads, because there were no default domain on model and res_id. bzr revid: tde@openerp.com-20120911141740-8t43y4hq5s79z34i --- addons/mail/static/src/js/mail.js | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/addons/mail/static/src/js/mail.js b/addons/mail/static/src/js/mail.js index 9a8de1480de..6eedabb23b8 100644 --- a/addons/mail/static/src/js/mail.js +++ b/addons/mail/static/src/js/mail.js @@ -416,12 +416,12 @@ openerp.mail = function(session) { // domain and context: options + additional fetch_domain = _.flatten([this.options.domain, additional_domain || []], true) fetch_context = _.extend(this.options.context, additional_context || {}) - // if message_ids is set: try to use it + // initial mode: try to use message_data or message_ids if (initial_mode && this.options.message_data) { return this.message_display(this.options.message_data); } - return this.ds_message.call('message_read', - [(initial_mode && this.options.message_ids) || false, fetch_domain, this.options.thread_level, undefined, fetch_context] + message_ids = initial_mode && this.options.message_ids != null && this.options.message_ids || false; + return this.ds_message.call('message_read', [message_ids, fetch_domain, this.options.thread_level, undefined, fetch_context] ).then(this.proxy('message_display')); }, @@ -604,13 +604,16 @@ openerp.mail = function(session) { _.extend(this.options.context, { default_res_id: this.view.datarecord.id, default_model: this.view.model }); + // update domain + var domain = this.options.domain.concat([['model', '=', this.view.model], ['res_id', '=', this.view.datarecord.id]]); // create and render Thread widget this.$el.find('div.oe_mail_recthread_main').empty(); if (this.thread) { this.thread.destroy(); } var thread = new mail.Thread(self, { - 'context': this.options.context, 'message_ids': this.get_value(), - 'thread_level': this.options.thread_level, 'show_header_compose': true, - 'show_delete': true, 'composer': true }); + 'context': this.options.context, 'domain': domain, 'message_ids': this.get_value(), + // display + 'thread_level': this.options.thread_level, 'show_header_compose': true, 'show_delete': true, 'composer': true, + }); this.thread = thread; return thread.appendTo(this.$el.find('div.oe_mail_recthread_main')); }, @@ -702,13 +705,13 @@ openerp.mail = function(session) { /** Display the Wall threads */ message_display: function () { - var thread_domain = this.options.domain.concat(this.search_results['domain']); + var domain = this.options.domain.concat(this.search_results['domain']); var render_res = session.web.qweb.render('mail.wall_thread_container', {}); $('
  • ').html(render_res).appendTo(this.$el.find('ul.oe_mail_wall_threads')); var thread = new mail.Thread(this, { - 'domain': thread_domain, 'context': this.options.context, - 'thread_level': this.options.thread_level, 'composer': true, + 'context': this.options.context, 'domain': domain, // display options + 'thread_level': this.options.thread_level, 'composer': true, 'show_header_compose': true, 'show_reply': this.options.thread_level > 0, 'show_hide': true, 'show_reply_by_email': true, } From 8aba3e02104ae4ba8551f3895182b457a64a0f02 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thibault=20Delavall=C3=A9e?= Date: Tue, 11 Sep 2012 18:17:00 +0200 Subject: [PATCH 16/24] [IMP] Chatter: added option to delete attachments in composer. bzr revid: tde@openerp.com-20120911161700-ty7h844h6f0t7nea --- addons/mail/static/src/css/mail.css | 3 +++ addons/mail/static/src/js/mail.js | 27 ++++++++++++++++++--------- addons/mail/static/src/xml/mail.xml | 7 ++++++- 3 files changed, 27 insertions(+), 10 deletions(-) diff --git a/addons/mail/static/src/css/mail.css b/addons/mail/static/src/css/mail.css index 9aa7bd1dfe3..ab8e9e7d917 100644 --- a/addons/mail/static/src/css/mail.css +++ b/addons/mail/static/src/css/mail.css @@ -410,3 +410,6 @@ padding: 0; list-style-type: square; } +.openerp .oe_mail_msg_content a.oe_mail_attachment_delete { + cursor: pointer; +} diff --git a/addons/mail/static/src/js/mail.js b/addons/mail/static/src/js/mail.js index 6eedabb23b8..bac87753574 100644 --- a/addons/mail/static/src/js/mail.js +++ b/addons/mail/static/src/js/mail.js @@ -108,6 +108,7 @@ openerp.mail = function(session) { this.options.context = options.context || {}; this.options.form_xml_id = options.form_xml_id || 'email_compose_message_wizard_form_chatter'; this.options.form_view_id = options.form_view_id || false; + this.show_attachment_delete = true; }, start: function () { @@ -157,20 +158,30 @@ openerp.mail = function(session) { var input_node = this.$el.find('input[name=ufile]'); button_attach.detach().insertAfter(input_node); // set the function called when attachments are added - this.$el.find('input.oe_form_binary_file').change(this.on_attachment_changed); + this.$el.find('input.oe_form_binary_file').change(this.on_attachment_change); this.bind_events(); this.form_view.do_show(); }, - /** Called when the user submits a new attachment */ - on_attachment_changed: function(e) { - var $e = $(e.target); - if ($e.val() !== '') { + on_attachment_change: function (event) { + var $target = $(event.target); + if ($target.val() !== '') { this.$el.find('form.oe_form_binary_form').submit(); session.web.blockUI(); } }, + on_attachment_delete: function (event) { + if (event.target.dataset && event.target.dataset.id) { + var attachment_id = parseInt(event.target.dataset.id); + var idx = _.pluck(this.attachment_ids, 'id').indexOf(attachment_id); + if (idx == -1) return false; + new session.web.DataSetSearch(this, 'ir.attachment').unlink(attachment_id); + this.attachment_ids.splice(idx, 1); + this.display_attachments(); + } + }, + display_attachments: function () { var attach_node = this.$el.find('div.oe_mail_compose_message_attachments'); var rendered = session.web.qweb.render('mail.thread.message.attachments', {'record': this}); @@ -205,10 +216,6 @@ openerp.mail = function(session) { * in the function. */ bind_events: function() { var self = this; - // event: click on 'Attachment' button that opens the dialog to add an attachment. - this.$el.on('click', 'button.oe_mail_compose_message_attachment', function (event) { - event.stopImmediatePropagation(); - }); // event: add a new attachment $(window).on(this.fileupload_id, function() { var args = [].slice.call(arguments).slice(1); @@ -218,6 +225,8 @@ openerp.mail = function(session) { self.display_attachments(); session.web.unblockUI(); }); + // event: delete an attachment + this.$el.on('click', '.oe_mail_attachment_delete', self.on_attachment_delete); }, }), diff --git a/addons/mail/static/src/xml/mail.xml b/addons/mail/static/src/xml/mail.xml index 18204c05f5b..c3787f50122 100644 --- a/addons/mail/static/src/xml/mail.xml +++ b/addons/mail/static/src/xml/mail.xml @@ -169,7 +169,12 @@
      -
    • +
    • + + + x + +
    From 309e2353c6ddbc1e60d9bd7aac7149a2c5f67b84 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thibault=20Delavall=C3=A9e?= Date: Tue, 11 Sep 2012 18:24:15 +0200 Subject: [PATCH 17/24] [CLEAN] mail.js: some cleaning in Wall and RecordThread. bzr revid: tde@openerp.com-20120911162415-altimitaw1nz2r03 --- addons/mail/static/src/js/mail.js | 17 ++--------------- addons/mail/static/src/xml/mail.xml | 4 ++-- 2 files changed, 4 insertions(+), 17 deletions(-) diff --git a/addons/mail/static/src/js/mail.js b/addons/mail/static/src/js/mail.js index bac87753574..858256ff476 100644 --- a/addons/mail/static/src/js/mail.js +++ b/addons/mail/static/src/js/mail.js @@ -597,11 +597,6 @@ openerp.mail = function(session) { this.$el.toggle(this.view.get("actual_mode") !== "create"); }, - destroy: function() { - if (this.thread) { this.thread.destroy(); } - this._super.apply(this, arguments); - }, - set_value: function() { var self = this; this._super.apply(this, arguments); @@ -617,13 +612,11 @@ openerp.mail = function(session) { var domain = this.options.domain.concat([['model', '=', this.view.model], ['res_id', '=', this.view.datarecord.id]]); // create and render Thread widget this.$el.find('div.oe_mail_recthread_main').empty(); - if (this.thread) { this.thread.destroy(); } var thread = new mail.Thread(self, { 'context': this.options.context, 'domain': domain, 'message_ids': this.get_value(), // display 'thread_level': this.options.thread_level, 'show_header_compose': true, 'show_delete': true, 'composer': true, }); - this.thread = thread; return thread.appendTo(this.$el.find('div.oe_mail_recthread_main')); }, }); @@ -666,11 +659,6 @@ openerp.mail = function(session) { return (search_view_ready && thread_displayed); }, - destroy: function () { - if (this.thread) this.thread.destroy(); - this._super.apply(this, arguments); - }, - /** * Load the mail.message search view * @param {Object} defaults ?? @@ -716,7 +704,7 @@ openerp.mail = function(session) { message_display: function () { var domain = this.options.domain.concat(this.search_results['domain']); var render_res = session.web.qweb.render('mail.wall_thread_container', {}); - $('
  • ').html(render_res).appendTo(this.$el.find('ul.oe_mail_wall_threads')); + $(render_res).appendTo(this.$el.find('ul.oe_mail_wall_threads')); var thread = new mail.Thread(this, { 'context': this.options.context, 'domain': domain, // display options @@ -725,8 +713,7 @@ openerp.mail = function(session) { 'show_hide': true, 'show_reply_by_email': true, } ); - thread.appendTo(this.$el.find('li.oe_mail_wall_thread:last')); - this.thread = thread; + return thread.appendTo(this.$el.find('li.oe_mail_wall_thread:last')); }, }); }; diff --git a/addons/mail/static/src/xml/mail.xml b/addons/mail/static/src/xml/mail.xml index c3787f50122..601270cc98f 100644 --- a/addons/mail/static/src/xml/mail.xml +++ b/addons/mail/static/src/xml/mail.xml @@ -39,8 +39,8 @@ wall_thread_container template for the wall Each discussion thread is contained inside this template --> - - +
  • +
  • -
  • Quote and reply
  • +
  • Quote and reply
  • Details
  • @@ -142,12 +142,12 @@
  • -
  • Reply
  • +
  • Reply
  • - + 1 Attachment Attachments From ab82f7a9acc6273bdba123083cbd1b0b77f7b6e0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thibault=20Delavall=C3=A9e?= Date: Wed, 12 Sep 2012 11:21:43 +0200 Subject: [PATCH 19/24] [IMP] mail.js: fixed cleaning of composer after posting a comment; cleaned a bit js and css. bzr revid: tde@openerp.com-20120912092143-7bih2gmoa3tm1jyn --- addons/mail/static/src/css/mail.css | 39 +++++++++++------------- addons/mail/static/src/js/mail.js | 47 +++++++++++++++-------------- addons/mail/static/src/xml/mail.xml | 6 ++-- 3 files changed, 45 insertions(+), 47 deletions(-) diff --git a/addons/mail/static/src/css/mail.css b/addons/mail/static/src/css/mail.css index e2aa3451f31..5ca4542b1fe 100644 --- a/addons/mail/static/src/css/mail.css +++ b/addons/mail/static/src/css/mail.css @@ -230,6 +230,10 @@ clear: both; } +.openerp .oe_mail_msg_content a { + cursor: pointer; +} + .openerp img.oe_mail_icon { width: 50px; height: 50px; @@ -345,31 +349,20 @@ text-decoration: none; } -.openerp .oe_mail_msg_footer { - color: #888; -} - -.openerp .oe_mail_msg_footer li { - float: left; - margin-right: 3px; -} - -.openerp .oe_mail_msg_body { +.openerp .oe_mail_msg .oe_mail_msg_body { margin-bottom: .5em; text-align: justify; } -.openerp .oe_mail_msg_record_body pre { +.openerp .oe_mail_msg .oe_mail_msg_body pre { font-family: "Lucida Grande", Helvetica, Verdana, Arial, sans-serif; margin: 0px; -} - -.openerp .oe_mail_msg_body span.oe_mail_msg_tail { + white-space: pre-wrap; display: inline; } /* Read more/less link */ -.openerp .oe_mail_msg_content .oe_mail_reduce { +.openerp .oe_mail_msg span.oe_mail_reduce { position: absolute; right: 0; } @@ -387,11 +380,18 @@ border-top: 4px solid #404040; } -.openerp .oe_mail_msg_footer li:after { +/* Message fopoter */ +.openerp .oe_mail_msg .oe_mail_msg_footer { + color: #888; +} +.openerp .oe_mail_msg .oe_mail_msg_footer li { + float: left; + margin-right: 3px; +} +.openerp .oe_mail_msg .oe_mail_msg_footer li:after { content: " ยท "; } - -.openerp .oe_mail_msg_footer li:last-child:after { +.openerp .oe_mail_msg .oe_mail_msg_footer li:last-child:after { content: ""; } @@ -410,6 +410,3 @@ padding: 0; list-style-type: square; } -.openerp .oe_mail_msg_content a { - cursor: pointer; -} diff --git a/addons/mail/static/src/js/mail.js b/addons/mail/static/src/js/mail.js index ee08ff27d3d..a9d56e02cb7 100644 --- a/addons/mail/static/src/js/mail.js +++ b/addons/mail/static/src/js/mail.js @@ -281,6 +281,7 @@ openerp.mail = function(session) { this.ds_message = new session.web.DataSetSearch(this, 'mail.message'); // display customization vars this.display = { + show_record_name: true, truncate_limit: options.truncate_limit || 250, show_header_compose: options.show_header_compose || false, show_reply: options.show_reply || false, @@ -380,7 +381,7 @@ openerp.mail = function(session) { 'default_parent_id': this.options.default_parent_id, 'default_content_subtype': 'plain'} ); } - return this._super(action, on_close); + // return this._super(action, on_close); }, /** Instantiate the composition form, with every parameters in context @@ -486,7 +487,7 @@ openerp.mail = function(session) { // render, add the expand feature var rendered = session.web.qweb.render('mail.thread.message', {'record': record, 'thread': this, 'params': this.options, 'display': this.display}); $(rendered).appendTo(this.$el.children('div.oe_mail_thread_display:first')); - this.$el.find('div.oe_mail_msg_record_body').expander({ + this.$el.find('div.oe_mail_msg_body').expander({ slicePoint: this.options.msg_more_limit, expandText: 'read more', userCollapseText: '[^]', @@ -633,9 +634,11 @@ openerp.mail = function(session) { /** * @param {Object} parent parent * @param {Object} [options] - * @param {Number} [options.domain] domain on the Wall, is an array. - * @param {Number} [options.domain] context, is an object. It should + * @param {Array} [options.domain] domain on the Wall + * @param {Object} [options.context] context, is an object. It should * contain default_model, default_res_id, to give it to the threads. + * @param {Number} [options.thread_level] number of thread levels to display + * 0 being flat. */ init: function (parent, options) { this._super(parent); @@ -649,9 +652,9 @@ openerp.mail = function(session) { start: function () { this._super.apply(this, arguments); - var search_view_ready = this.load_search_view({}, false); - var thread_displayed = this.message_display(); - return (search_view_ready && thread_displayed); + var searchview_ready = this.load_searchview({}, false); + var thread_displayed = this.message_render(); + return (searchview_ready && thread_displayed); }, /** @@ -659,7 +662,7 @@ openerp.mail = function(session) { * @param {Object} defaults ?? * @param {Boolean} hidden some kind of trick we do not care here */ - load_search_view: function (defaults, hidden) { + load_searchview: function (defaults, hidden) { var self = this; this.searchview = new session.web.SearchView(this, this.ds_msg, false, defaults || {}, hidden || false); return this.searchview.appendTo(this.$el.find('.oe_view_manager_view_search')).then(function () { @@ -668,9 +671,8 @@ openerp.mail = function(session) { }, /** - * Aggregate the domains, contexts and groupbys in parameter - * with those from search form, and then calls fetch_comments - * to actually fetch comments + * Get the domains, contexts and groupbys in parameter from search + * view, then render the filtered threads. * @param {Array} domains * @param {Array} contexts * @param {Array} groupbys @@ -685,27 +687,26 @@ openerp.mail = function(session) { self.search_results['context'] = results.context; self.search_results['domain'] = results.domain; self.search_results['groupby'] = results.group_by; - self.message_clean(); - return self.message_display(); + return self.message_render(); }); }, - /** Clean the wall */ - message_clean: function() { + /** Cleand and display the threads */ + message_render: function () { this.$el.find('ul.oe_mail_wall_threads').empty(); - }, - - /** Display the Wall threads */ - message_display: function () { var domain = this.options.domain.concat(this.search_results['domain']); var render_res = session.web.qweb.render('mail.wall_thread_container', {}); $(render_res).appendTo(this.$el.find('ul.oe_mail_wall_threads')); var thread = new mail.Thread(this, { - 'context': this.options.context, 'domain': domain, + 'context': this.options.context, + 'domain': domain, // display options - 'thread_level': this.options.thread_level, 'composer': true, - 'show_header_compose': true, 'show_reply': this.options.thread_level > 0, - 'show_hide': true, 'show_reply_by_email': true, + 'thread_level': this.options.thread_level, + 'composer': true, + 'show_header_compose': true, + 'show_reply': this.options.thread_level > 0, + 'show_hide': true, + 'show_reply_by_email': true, } ); return thread.appendTo(this.$el.find('li.oe_mail_wall_thread:last')); diff --git a/addons/mail/static/src/xml/mail.xml b/addons/mail/static/src/xml/mail.xml index da1ba28b849..09da919a78d 100644 --- a/addons/mail/static/src/xml/mail.xml +++ b/addons/mail/static/src/xml/mail.xml @@ -132,10 +132,10 @@
    -
    + - -
    + +
    ', message.body, 'mail.message body is incorrect') + self.assertEqual(message.parent_id and message.parent_id.id, parent_id, 'mail.message parent_id incorrect') # Test: mail.message: attachments for attach in message.attachment_ids: self.assertEqual(attach.res_model, 'mail.group', 'mail.message attachment res_model incorrect') diff --git a/addons/mail/wizard/mail_compose_message.py b/addons/mail/wizard/mail_compose_message.py index ccb592755cc..03c5a7cfe8b 100644 --- a/addons/mail/wizard/mail_compose_message.py +++ b/addons/mail/wizard/mail_compose_message.py @@ -116,7 +116,7 @@ class mail_compose_message(osv.TransientModel): 'composition_mode': 'comment', 'content_subtype': lambda self, cr, uid, ctx={}: 'plain', 'body_text': lambda self, cr, uid, ctx={}: False, - 'body': lambda self, cr, uid, ctx={}: False, + 'body': lambda self, cr, uid, ctx={}: '', 'subject': lambda self, cr, uid, ctx={}: False, 'partner_ids': lambda self, cr, uid, ctx={}: [], } @@ -154,7 +154,7 @@ class mail_compose_message(osv.TransientModel): # create subject re_prefix = _('Re:') reply_subject = tools.ustr(message_data.subject or '') - if not (reply_subject.startswith('Re:') or reply_subject.startswith(re_prefix)): + if not (reply_subject.startswith('Re:') or reply_subject.startswith(re_prefix)) and message_data.subject: reply_subject = "%s %s" % (re_prefix, reply_subject) # create the reply in the body reply_body = _('
    On %(date)s, %(sender_name)s wrote:
    %(body)s
    ') % { @@ -250,6 +250,7 @@ class mail_compose_message(osv.TransientModel): post_values = { 'subject': wizard.subject if wizard.content_subtype == 'html' else False, 'body': wizard.body if wizard.content_subtype == 'html' else '
    %s
    ' % tools.ustr(wizard.body_text), + 'parent_id': wizard.parent_id and wizard.parent_id.id, 'partner_ids': [(4, partner.id) for partner in wizard.partner_ids], 'attachments': [(attach.datas_fname or attach.name, base64.b64decode(attach.datas)) for attach in wizard.attachment_ids], } From 6de7585204c8d6d7625ee243a7ca0269a0f87da4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thibault=20Delavall=C3=A9e?= Date: Wed, 12 Sep 2012 12:22:17 +0200 Subject: [PATCH 22/24] [CLEAN] mail.js: cleaned init of Thread widget (do not pass everything in options, but explicitely domain, context, options). Cleaned some var names, propagated change in code. Added reply_by_email for a reply link that does a quote and reply. Dropdown options are now prefixed with a dd. bzr revid: tde@openerp.com-20120912102217-q6xnkn749how9en4 --- addons/mail/static/src/js/mail.js | 110 ++++++++++++++-------------- addons/mail/static/src/xml/mail.xml | 43 +++++------ 2 files changed, 76 insertions(+), 77 deletions(-) diff --git a/addons/mail/static/src/js/mail.js b/addons/mail/static/src/js/mail.js index a9d56e02cb7..ae66b4eae86 100644 --- a/addons/mail/static/src/js/mail.js +++ b/addons/mail/static/src/js/mail.js @@ -262,34 +262,33 @@ openerp.mail = function(session) { * display before having a "show more" link; note that the text * will not be truncated if it does not have 110% of the parameter */ - init: function(parent, options) { + init: function(parent, domain, context, options) { this._super(parent); - // options - this.options = options || {}; - this.options.domain = options.domain || []; - this.options.context = _.extend({ + this.domain = domain || []; + this.context = _.extend({ default_model: 'mail.thread', default_res_id: 0, - default_parent_id: false }, options.context || {}); - this.options.thread_level = options.thread_level || 0; - this.options.composer = options.composer || false; - this.options.message_ids = options.message_ids || null; - this.options.message_data = options.message_data || null; + default_parent_id: false }, context || {}); + // options + this.options = { + message_ids: options.message_ids || null, + message_data: options.message_data || null, + thread_level: options.thread_level || 0, + use_composer: options.use_composer || false, + show_header_compose: options.show_header_compose != undefined ? options.show_header_compose: true, + show_record_name: options.show_record_name != undefined ? options.show_record_name: true, + show_reply: options.show_reply || false, + show_reply_by_email: options.show_reply_by_email || false, + show_dd_reply_by_email:options.show_dd_reply_by_email != undefined ? options.show_dd_reply_by_email: true, + show_dd_delete: options.show_dd_delete || false, + show_dd_hide: options.show_dd_hide || false, + show_more: options.show_more || false, + truncate_limit: options.truncate_limit || 250, + } // datasets and internal vars - this.ds_thread = new session.web.DataSetSearch(this, this.options.context.default_model); + this.ds_thread = new session.web.DataSetSearch(this, this.context.default_model); this.ds_notification = new session.web.DataSetSearch(this, 'mail.notification'); this.ds_message = new session.web.DataSetSearch(this, 'mail.message'); - // display customization vars - this.display = { - show_record_name: true, - truncate_limit: options.truncate_limit || 250, - show_header_compose: options.show_header_compose || false, - show_reply: options.show_reply || false, - show_delete: options.show_delete || false, - show_hide: options.show_hide || false, - show_reply_by_email: options.show_reply_by_email || false, - show_more: options.show_more || false, - } }, start: function() { @@ -299,7 +298,7 @@ openerp.mail = function(session) { // fetch and display message, using message_ids if set var display_done = $.when(this.message_fetch(true, [], {})).then(this.proxy('do_customize_display')); // add message composition form view - if (this.display.show_header_compose && this.options.composer) { + if (this.options.show_header_compose && this.options.use_composer) { var compose_done = this.instantiate_composition_form(); } return display_done && compose_done; @@ -309,7 +308,9 @@ openerp.mail = function(session) { * - show_header_compose: show the composition form in the header */ do_customize_display: function() { this.display_user_avatar(); - if (this.display.show_header_compose) { this.$el.find('div.oe_mail_thread_action').eq(0).show(); } + if (this.options.show_header_compose) { + this.$el.find('div.oe_mail_thread_action').eq(0).show(); + } }, /** @@ -378,7 +379,7 @@ openerp.mail = function(session) { if (this.compose_message_widget) { this.compose_message_widget.refresh({ 'default_composition_mode': 'comment', - 'default_parent_id': this.options.default_parent_id, + 'default_parent_id': this.context.default_parent_id, 'default_content_subtype': 'plain'} ); } // return this._super(action, on_close); @@ -391,7 +392,7 @@ openerp.mail = function(session) { this.compose_message_widget.destroy(); } this.compose_message_widget = new mail.ComposeMessage(this, { - 'context': _.extend(context || {}, this.options.context), + 'context': _.extend(context || {}, this.context), }); var composition_node = this.$el.find('div.oe_mail_thread_action'); composition_node.empty(); @@ -413,14 +414,14 @@ openerp.mail = function(session) { * @param {Bool} initial_mode: initial mode: try to use message_data or * message_ids, if nothing available perform a message_read; otherwise * directly perform a message_read - * @param {Array} additional_domain: added to options.domain - * @param {Object} additional_context: added to options.context + * @param {Array} additional_domain: added to this.domain + * @param {Object} additional_context: added to this.context */ message_fetch: function (initial_mode, additional_domain, additional_context) { var self = this; // domain and context: options + additional - fetch_domain = _.flatten([this.options.domain, additional_domain || []], true) - fetch_context = _.extend(this.options.context, additional_context || {}) + fetch_domain = _.flatten([this.domain, additional_domain || []], true) + fetch_context = _.extend(this.context, additional_context || {}) // initial mode: try to use message_data or message_ids if (initial_mode && this.options.message_data) { return this.message_display(this.options.message_data); @@ -446,15 +447,17 @@ openerp.mail = function(session) { } else { self.display_record(record); - self.thread = new mail.Thread(self, { - 'context': { - 'default_model': record.model, + self.thread = new mail.Thread(self, self.domain, + { 'default_model': record.model, 'default_res_id': record.res_id, 'default_parent_id': record.id }, - 'message_data': record.child_ids, 'thread_level': self.options.thread_level-1, - 'show_header_compose': false, 'show_reply': self.options.thread_level > 1, - 'show_hide': self.display.show_hide, 'show_delete': self.display.show_delete, - }); + { 'message_data': record.child_ids, + 'thread_level': self.options.thread_level - 1, + 'show_header_compose': false, + 'show_reply': self.options.show_reply && self.options.thread_level > 1, + 'show_reply_by_email': self.options.show_reply_by_email, + 'show_dd_hide': self.options.show_dd_hide, + 'show_dd_delete': self.options.show_dd_delete }); self.$el.find('li.oe_mail_thread_msg:last').append('
    '); self.thread.appendTo(self.$el.find('div.oe_mail_thread_subthread:last')); } @@ -485,10 +488,10 @@ openerp.mail = function(session) { } record.is_author = mail.ChatterUtils.is_author(this, record.author_user_id[0]); // render, add the expand feature - var rendered = session.web.qweb.render('mail.thread.message', {'record': record, 'thread': this, 'params': this.options, 'display': this.display}); + var rendered = session.web.qweb.render('mail.thread.message', {'record': record, 'thread': this, 'options': this.options}); $(rendered).appendTo(this.$el.children('div.oe_mail_thread_display:first')); this.$el.find('div.oe_mail_msg_body').expander({ - slicePoint: this.options.msg_more_limit, + slicePoint: this.options.truncate_limit, expandText: 'read more', userCollapseText: '[^]', detailClass: 'oe_mail_msg_tail', @@ -519,7 +522,7 @@ openerp.mail = function(session) { comment_node.val(''); } return this.ds_thread.call('message_post', [ - [this.options.context.default_res_id], body, false, 'comment', this.options.context.default_parent_id, undefined] + [this.context.default_res_id], body, false, 'comment', this.context.default_parent_id, undefined] ).then(self.message_fetch()); }, @@ -608,11 +611,11 @@ openerp.mail = function(session) { var domain = this.options.domain.concat([['model', '=', this.view.model], ['res_id', '=', this.view.datarecord.id]]); // create and render Thread widget this.$el.find('div.oe_mail_recthread_main').empty(); - var thread = new mail.Thread(self, { - 'context': this.options.context, 'domain': domain, 'message_ids': this.get_value(), - // display - 'thread_level': this.options.thread_level, 'show_header_compose': true, 'show_delete': true, 'composer': true, - }); + var thread = new mail.Thread(self, domain, this.options.context, + { 'thread_level': this.options.thread_level, + 'use_composer': true, + 'show_dd_delete': true, + 'show_reply_by_email': true }); return thread.appendTo(this.$el.find('div.oe_mail_recthread_main')); }, }); @@ -691,22 +694,17 @@ openerp.mail = function(session) { }); }, - /** Cleand and display the threads */ + /** Clean and display the threads */ message_render: function () { this.$el.find('ul.oe_mail_wall_threads').empty(); var domain = this.options.domain.concat(this.search_results['domain']); var render_res = session.web.qweb.render('mail.wall_thread_container', {}); $(render_res).appendTo(this.$el.find('ul.oe_mail_wall_threads')); - var thread = new mail.Thread(this, { - 'context': this.options.context, - 'domain': domain, - // display options - 'thread_level': this.options.thread_level, - 'composer': true, - 'show_header_compose': true, - 'show_reply': this.options.thread_level > 0, - 'show_hide': true, - 'show_reply_by_email': true, + var thread = new mail.Thread(this, domain, this.options.context, + { 'thread_level': this.options.thread_level, + 'use_composer': true, + 'show_reply': this.options.thread_level > 0, + 'show_dd_hide': true, } ); return thread.appendTo(this.$el.find('li.oe_mail_wall_thread:last')); diff --git a/addons/mail/static/src/xml/mail.xml b/addons/mail/static/src/xml/mail.xml index 09da919a78d..4d3b56cf62f 100644 --- a/addons/mail/static/src/xml/mail.xml +++ b/addons/mail/static/src/xml/mail.xml @@ -114,16 +114,14 @@ @@ -132,26 +130,29 @@
    - - + +
    From 55c236dad7ec6fdde4183eaebcbda92a60b55903 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thibault=20Delavall=C3=A9e?= Date: Wed, 12 Sep 2012 12:40:11 +0200 Subject: [PATCH 23/24] [CLEAN] mail.js: cleaned Thread comments. bzr revid: tde@openerp.com-20120912104011-05qvefxxya8t70iw --- addons/mail/static/src/js/mail.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/addons/mail/static/src/js/mail.js b/addons/mail/static/src/js/mail.js index ae66b4eae86..03c79a6b54b 100644 --- a/addons/mail/static/src/js/mail.js +++ b/addons/mail/static/src/js/mail.js @@ -248,15 +248,16 @@ openerp.mail = function(session) { /** * @param {Object} parent parent - * @param {Object} [options] - * @param {Object} [options.context] context of the thread. It should + * @param {Array} [domain] + * @param {Object} [context] context of the thread. It should contain at least default_model, default_res_id. Please refer to the ComposeMessage widget for more information about it. - * @param {Number} [options.thread_level=0] number of thread levels + * @param {Object} [options] * @param {Number} [options.message_ids=null] ids for message_fetch * @param {Number} [options.message_data=null] already formatted message data, for subthreads getting data from their parent - * @param {Boolean} [options.composer] use the advanced composer, or + * @param {Number} [options.thread_level=0] number of thread levels + * @param {Boolean} [options.use_composer] use the advanced composer, or the default basic textarea if not set * @param {Number} [options.truncate_limit=250] number of character to * display before having a "show more" link; note that the text From f5ebe79d3898472ec4f2113336d8103268c5daaa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thibault=20Delavall=C3=A9e?= Date: Wed, 12 Sep 2012 13:28:32 +0200 Subject: [PATCH 24/24] [FIX] Chatter: attachments are now also cleaned after posting. bzr revid: tde@openerp.com-20120912112832-qy0yhzaee7g0f6p7 --- addons/mail/static/src/js/mail.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/addons/mail/static/src/js/mail.js b/addons/mail/static/src/js/mail.js index 03c79a6b54b..71665bc69fb 100644 --- a/addons/mail/static/src/js/mail.js +++ b/addons/mail/static/src/js/mail.js @@ -205,10 +205,14 @@ openerp.mail = function(session) { this.options.context = _.extend(this.options.context, new_context || {}); this.ds_compose.context = _.extend(this.ds_compose.context, this.options.context); return this.ds_compose.call('default_get', [ - ['subject', 'body_text', 'body', 'attachment_ids', 'partner_ids', 'composition_mode', + ['subject', 'body_text', 'body', 'partner_ids', 'composition_mode', 'use_template', 'template_id', 'model', 'res_id', 'parent_id', 'content_subtype'], this.ds_compose.get_context(), - ]).then( function (result) { self.form_view.on_processed_onchange({'value': result}, []); }); + ]).then( function (result) { + self.form_view.on_processed_onchange({'value': result}, []); + self.attachment_ids = []; + self.display_attachments(); + }); }, /**