From edb1e07948416d12351dbc9e5d4b9896a53f0de7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thibault=20Delavall=C3=A9e?= Date: Thu, 15 Nov 2012 10:53:09 +0100 Subject: [PATCH 1/8] [FIX] composer: default content subtype is html (note that plaintext management will be removed asap), name_get is now using an id list instead of a single id. bzr revid: tde@openerp.com-20121115095309-zu4m6nzndlpmfe5b --- addons/mail/wizard/mail_compose_message.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/addons/mail/wizard/mail_compose_message.py b/addons/mail/wizard/mail_compose_message.py index 45082b9be4d..839a3a6970e 100644 --- a/addons/mail/wizard/mail_compose_message.py +++ b/addons/mail/wizard/mail_compose_message.py @@ -114,7 +114,7 @@ class mail_compose_message(osv.TransientModel): _defaults = { 'composition_mode': 'comment', - 'content_subtype': lambda self, cr, uid, ctx={}: 'plain', + 'content_subtype': lambda self, cr, uid, ctx={}: 'html', 'body_text': lambda self, cr, uid, ctx={}: False, 'body': lambda self, cr, uid, ctx={}: '', 'subject': lambda self, cr, uid, ctx={}: False, @@ -135,7 +135,7 @@ class mail_compose_message(osv.TransientModel): related to. :param int res_id: id of the document record this mail is related to """ - doc_name_get = self.pool.get(model).name_get(cr, uid, res_id, context=context) + doc_name_get = self.pool.get(model).name_get(cr, uid, [res_id], context=context) if doc_name_get: record_name = doc_name_get[0][1] else: From 71c2be227cd1a8188db6f961d7d358099873e37a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thibault=20Delavall=C3=A9e?= Date: Thu, 15 Nov 2012 10:53:29 +0100 Subject: [PATCH 2/8] [IMP] mail: updated tests to fit the new composer behavior. bzr revid: tde@openerp.com-20121115095329-whh6z7ckto87yven --- addons/mail/tests/test_mail.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/addons/mail/tests/test_mail.py b/addons/mail/tests/test_mail.py index 1cdb966ccbc..02b55cef9f7 100644 --- a/addons/mail/tests/test_mail.py +++ b/addons/mail/tests/test_mail.py @@ -463,7 +463,8 @@ class test_mail(test_mail_mockup.TestMailMockups): # 1. Comment group_pigs with body_text and subject compose_id = mail_compose.create(cr, uid, {'subject': _subject, 'body_text': _body_text, 'partner_ids': [(4, p_c_id), (4, p_d_id)]}, - {'default_composition_mode': 'comment', 'default_model': 'mail.group', 'default_res_id': self.group_pigs_id}) + {'default_composition_mode': 'comment', 'default_model': 'mail.group', 'default_res_id': self.group_pigs_id, + 'default_content_subtype': 'plaintext'}) compose = mail_compose.browse(cr, uid, compose_id) # Test: mail.compose.message: composition_mode, model, res_id self.assertEqual(compose.composition_mode, 'comment', 'mail.compose.message incorrect composition_mode') From 25c684b1712796fad879596d19fa27cafbe03846 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thibault=20Delavall=C3=A9e?= Date: Thu, 15 Nov 2012 10:54:00 +0100 Subject: [PATCH 3/8] [FIX] Chatter: fixed posting on user/partner. Cleaned a bit default options of mail.js. bzr revid: tde@openerp.com-20121115095400-u7h6rw8ltp0xprtt --- addons/mail/mail_thread_view.xml | 2 +- addons/mail/res_partner.py | 3 ++- addons/mail/res_users.py | 11 ++++------- addons/mail/static/src/js/mail.js | 8 ++------ 4 files changed, 9 insertions(+), 15 deletions(-) diff --git a/addons/mail/mail_thread_view.xml b/addons/mail/mail_thread_view.xml index cdeade04d84..3a37218c813 100644 --- a/addons/mail/mail_thread_view.xml +++ b/addons/mail/mail_thread_view.xml @@ -7,7 +7,7 @@ mail.message { 'default_model': 'res.users', - 'default_res_id': uid + 'default_res_id': uid, } Date: Thu, 15 Nov 2012 11:05:33 +0100 Subject: [PATCH 4/8] [FIX] Chatter: fixed rpely to a lonely message, that was badly indented. bzr revid: tde@openerp.com-20121115100533-ly99op6fpfrzp9jw --- addons/mail/static/src/js/mail.js | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/addons/mail/static/src/js/mail.js b/addons/mail/static/src/js/mail.js index 75852a9d9b1..37090543b8c 100644 --- a/addons/mail/static/src/js/mail.js +++ b/addons/mail/static/src/js/mail.js @@ -598,16 +598,15 @@ openerp.mail = function (session) { this.parent_thread.context ]).done(function (record) { var thread = self.parent_thread; - if (self.options.display_indented_thread < self.thread_level && thread.parent_message) { - thread = thread.parent_message.parent_thread; + var hread = thread.parent_message.parent_thread; } + var root = thread == self.options.root_thread; // create object and attach to the thread object thread.message_fetch([['id', 'child_of', [self.id]]], false, [record], function (arg, data) { - data[0].no_sorted = true; var message = thread.create_message_object( data[0] ); // insert the message on dom - thread.insert_message( message, self.$el ); + thread.insert_message( message, root ? undefined : self.$el, root ); if (thread.parent_message) { self.$el.remove(); self.parent_thread.compose_message = null; @@ -1272,7 +1271,7 @@ openerp.mail = function (session) { * The sort is define by the thread_level (O for newer on top). * @param : {object} ThreadMessage object */ - insert_message: function (message, dom_insert_after) { + insert_message: function (message, dom_insert_after, prepend) { var self=this; if (this.options.show_compact_message > this.thread_level) { this.instantiate_compose_message(); @@ -1284,6 +1283,8 @@ openerp.mail = function (session) { if (dom_insert_after) { message.insertAfter(dom_insert_after); + }if (prepend) { + message.prependTo(self.$el); } else { message.appendTo(self.$el); } From 15b23a76aeded2cff747d1dedaeab6ae6357eb27 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thibault=20Delavall=C3=A9e?= Date: Thu, 15 Nov 2012 11:35:01 +0100 Subject: [PATCH 5/8] [REM] Chatter: removed unused template in xml. bzr revid: tde@openerp.com-20121115103501-wt837acx8kj1ycht --- addons/mail/static/src/xml/mail.xml | 8 -------- 1 file changed, 8 deletions(-) diff --git a/addons/mail/static/src/xml/mail.xml b/addons/mail/static/src/xml/mail.xml index 2ba1733043a..89fbe45dc36 100644 --- a/addons/mail/static/src/xml/mail.xml +++ b/addons/mail/static/src/xml/mail.xml @@ -95,14 +95,6 @@ - -
- - This email is private. - I wrote for contacts and all my followers. -
-
- From 6227e4b5c04b9ee861511a45f7b50806e27cf33c Mon Sep 17 00:00:00 2001 From: Christophe Simonis Date: Thu, 15 Nov 2012 13:03:31 +0100 Subject: [PATCH 6/8] [FIX] CrashManager do not have destroy() method bzr revid: chs@openerp.com-20121115120331-ltujwzobh19muygl --- addons/web/static/src/js/chrome.js | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/addons/web/static/src/js/chrome.js b/addons/web/static/src/js/chrome.js index 2753cb45d1e..f5fc7b8f632 100644 --- a/addons/web/static/src/js/chrome.js +++ b/addons/web/static/src/js/chrome.js @@ -190,7 +190,14 @@ instance.web.Dialog = instance.web.Widget.extend({ }); instance.web.CrashManager = instance.web.Class.extend({ + init: function() { + this.active = true; + }, + rpc_error: function(error) { + if (!this.active) { + return; + } if (error.data.fault_code) { var split = ("" + error.data.fault_code).split('\n')[0].split(' -- '); if (split.length > 1) { @@ -205,6 +212,9 @@ instance.web.CrashManager = instance.web.Class.extend({ } }, show_warning: function(error) { + if (!this.active) { + return; + } instance.web.dialog($('
' + QWeb.render('CrashManager.warning', {error: error}) + '
'), { title: "OpenERP " + _.str.capitalize(error.type), buttons: [ @@ -213,7 +223,9 @@ instance.web.CrashManager = instance.web.Class.extend({ }); }, show_error: function(error) { - var self = this; + if (!this.active) { + return; + } var buttons = {}; buttons[_t("Ok")] = function() { $(this).dialog("close"); @@ -642,7 +654,7 @@ instance.web.client_actions.add("login", "instance.web.Login"); instance.web.redirect = function(url, wait) { // Dont display a dialog if some xmlhttprequest are in progress if (instance.client && instance.client.crashmanager) { - instance.client.crashmanager.destroy(); + instance.client.crashmanager.active = false; } var wait_server = function() { @@ -658,7 +670,7 @@ instance.web.redirect = function(url, wait) { } else { window.location = url; } -} +}; /** * Client action to reload the whole interface. From 81d4467c8fb4e15129d5dd6b8242fa1a8d4e5562 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thibault=20Delavall=C3=A9e?= Date: Thu, 15 Nov 2012 13:24:06 +0100 Subject: [PATCH 7/8] [REV] mail.compose.message using email_template: _reopen is back, as the spec of a wizard should be that hitting a button close it. Therefore _reopen is necessaru to reopen the wizard with its previous value, to continue working on it. bzr revid: tde@openerp.com-20121115122406-d88ozw5iclsqdyff --- .../wizard/mail_compose_message.py | 28 ++++++++++++++----- .../wizard/mail_compose_message_view.xml | 3 +- 2 files changed, 22 insertions(+), 9 deletions(-) diff --git a/addons/email_template/wizard/mail_compose_message.py b/addons/email_template/wizard/mail_compose_message.py index 129c32722f5..ba4cef83bdb 100644 --- a/addons/email_template/wizard/mail_compose_message.py +++ b/addons/email_template/wizard/mail_compose_message.py @@ -25,6 +25,21 @@ from osv import osv from osv import fields +def _reopen(self, res_id, model): + return {'type': 'ir.actions.act_window', + 'view_mode': 'form', + 'view_type': 'form', + 'res_id': res_id, + 'res_model': self._name, + 'target': 'new', + # save original model in context, because selecting the list of available + # templates requires a model in context + 'context': { + 'default_model': model, + }, + } + + class mail_compose_message(osv.TransientModel): _inherit = 'mail.compose.message' @@ -42,10 +57,8 @@ class mail_compose_message(osv.TransientModel): else: model = context.get('default_model', context.get('active_model')) - if model: - record_ids = email_template_obj.search(cr, uid, [('model', '=', model)], context=context) - return email_template_obj.name_get(cr, uid, record_ids, context) + [(False, '')] - return [] + record_ids = email_template_obj.search(cr, uid, [('model', '=', model)], context=context) + return email_template_obj.name_get(cr, uid, record_ids, context) + [(False, '')] def default_get(self, cr, uid, fields, context=None): if context is None: @@ -109,7 +122,7 @@ class mail_compose_message(osv.TransientModel): onchange_res['partner_ids'] = [(4, partner_id) for partner_id in onchange_res.pop('partner_ids', [])] onchange_res['attachment_ids'] = [(4, attachment_id) for attachment_id in onchange_res.pop('attachment_ids', [])] record.write(onchange_res) - return True + return _reopen(self, record.id, record.model) def onchange_use_template(self, cr, uid, ids, use_template, template_id, composition_mode, model, res_id, context=None): """ onchange_use_template (values: True or False). If use_template is @@ -141,8 +154,9 @@ class mail_compose_message(osv.TransientModel): 'attachment_ids': [(6, 0, [att.id for att in record.attachment_ids])] } template_id = email_template.create(cr, uid, values, context=context) - record.write({'template_id': template_id, 'use_template': True}) - return True + # record.write({'template_id': template_id, 'use_template': True}) + record.write(record.onchange_template_id(True, template_id, record.composition_mode, record.model, record.res_id)['value']) + return _reopen(self, record.id, record.model) #------------------------------------------------------ # Wizard validation and send diff --git a/addons/email_template/wizard/mail_compose_message_view.xml b/addons/email_template/wizard/mail_compose_message_view.xml index 0a530299d4a..5afaf9745e1 100644 --- a/addons/email_template/wizard/mail_compose_message_view.xml +++ b/addons/email_template/wizard/mail_compose_message_view.xml @@ -14,12 +14,11 @@ -
Use template +
Use template
- or