From e089d497031aefcc32b225a6958dda9812daf71b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thibault=20Delavall=C3=A9e?= Date: Tue, 11 Sep 2012 11:40:07 +0200 Subject: [PATCH 1/5] [FIX] sale, mail: fixed Send by email, back to a wizard. Cleaned a bit some code related to that action. bzr revid: tde@openerp.com-20120911094007-svlzik5kgmp4nuvy --- .../wizard/mail_compose_message.py | 6 +++-- addons/mail/static/src/js/mail.js | 24 +++++++++---------- addons/sale/sale.py | 11 ++++++--- 3 files changed, 24 insertions(+), 17 deletions(-) diff --git a/addons/email_template/wizard/mail_compose_message.py b/addons/email_template/wizard/mail_compose_message.py index 2baef6e6c90..c0cb7fc92e5 100644 --- a/addons/email_template/wizard/mail_compose_message.py +++ b/addons/email_template/wizard/mail_compose_message.py @@ -51,9 +51,11 @@ class mail_compose_message(osv.osv_memory): context = {} result = super(mail_compose_message, self).default_get(cr, uid, fields, context=context) result['template_id'] = context.get('default_template_id', context.get('mail.compose.template_id', False)) - # force html when using templates + # pre-render the template if any if result.get('use_template'): - result['content_subtype'] = 'html' + onchange_res = self.onchange_use_template(cr, uid, [], result.get('use_template'), result.get('template_id'), + result.get('composition_mode'), result.get('model'), result.get('res_id'), context=context) + result.update(onchange_res['value']) return result _columns = { diff --git a/addons/mail/static/src/js/mail.js b/addons/mail/static/src/js/mail.js index e8d8e25e684..3f23e65f00d 100644 --- a/addons/mail/static/src/js/mail.js +++ b/addons/mail/static/src/js/mail.js @@ -17,19 +17,15 @@ openerp.mail = function(session) { */ session.web.FormView = session.web.FormView.extend({ - // TDE FIXME TODO: CHECK WITH NEW BRANCH 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') { - // debug - console.groupCollapsed('FormView do_action on mail.compose.message'); - console.log('message_ids field:', this.fields.message_ids); - console.groupEnd(); var record_thread = this.fields.message_ids; var thread = record_thread.thread; - thread.instantiate_composition_form('comment', true, false, 0, action.context); - return false; + thread.refresh_composition_form(action.context); + return true; } else { return this._super(action, on_close); @@ -174,7 +170,7 @@ openerp.mail = function(session) { 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', - 'model', 'res_id', 'parent_id', 'content_subtype'], + '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}, []); }); }, @@ -365,6 +361,11 @@ openerp.mail = function(session) { return compose_done; }, + refresh_composition_form: function (context) { + if (! this.compose_message_widget) return; + return this.compose_message_widget.refresh(context); + }, + /** Clean the thread */ message_clean: function() { this.$el.find('div.oe_mail_thread_display').empty(); @@ -548,7 +549,6 @@ openerp.mail = function(session) { this.options.domain = this.options.domain || []; this.options.context = {'default_model': 'mail.thread', 'default_res_id': false}; this.options.thread_level = this.options.thread_level || 0; - this.thread_list = []; }, start: function() { @@ -564,7 +564,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); }, @@ -581,13 +581,13 @@ openerp.mail = function(session) { default_model: this.view.model }); // create and render Thread widget this.$el.find('div.oe_mail_recthread_main').empty(); - for (var i in this.thread_list) { this.thread_list[i].destroy(); } + if (this.thread) { this.thread.destroy(); } var thread = new mail.Thread(self, { 'context': this.options.context, 'thread_level': this.options.thread_level, 'show_header_compose': true, 'message_ids': this.get_value(), 'show_delete': true, 'composer': true }); - this.thread_list.push(thread); + this.thread = thread; return thread.appendTo(this.$el.find('div.oe_mail_recthread_main')); }, }); diff --git a/addons/sale/sale.py b/addons/sale/sale.py index 6a6678d6163..553b8993ab8 100644 --- a/addons/sale/sale.py +++ b/addons/sale/sale.py @@ -769,13 +769,18 @@ class sale_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='sale.order', active_id=ids[0]) - ctx.update({'mail.compose.template_id': template_id}) + ctx = dict(context) + ctx.update({ + 'default_model': 'sale.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 e5b0cd2091e53c5e0e08fc94461ebfb1797ce7dd Mon Sep 17 00:00:00 2001 From: Fabien Pinckaers Date: Tue, 11 Sep 2012 12:17:29 +0200 Subject: [PATCH 2/5] [IMP] Address Format in Reports bzr revid: fp@tinyerp.com-20120911101729-iv79hos2mwxopitq --- openerp/addons/base/res/res_partner.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/openerp/addons/base/res/res_partner.py b/openerp/addons/base/res/res_partner.py index 906f4b2b6c6..c5dbd53a15e 100644 --- a/openerp/addons/base/res/res_partner.py +++ b/openerp/addons/base/res/res_partner.py @@ -498,7 +498,7 @@ class res_partner(osv.osv): # get the information that will be injected into the display format # get the address format address_format = address.country_id and address.country_id.address_format or \ - '%(company_name)s\n%(street)s\n%(street2)s\n%(city)s,%(state_code)s %(zip)s' + "%(street)s\n%(street2)s\n%(city)s %(state_code)s %(zip)s\n%(country_name)s" args = { 'state_code': address.state_id and address.state_id.code or '', 'state_name': address.state_id and address.state_id.name or '', @@ -511,10 +511,10 @@ class res_partner(osv.osv): args[field] = getattr(address, field) or '' if without_company: args['company_name'] = '' + elif address.parent_id: + address_format = '%(company_name)s\n' + address_format return address_format % args - - # res.partner.address is deprecated; it is still there for backward compability only and will be removed in next version class res_partner_address(osv.osv): _table = "res_partner" From de5c80fb902c2992665d2011bf45f45ae8f4db26 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thibault=20Delavall=C3=A9e?= Date: Tue, 11 Sep 2012 13:52:38 +0200 Subject: [PATCH 3/5] [FIX] sale.order: fixed a typo in template, leading to the company not being displayed. bzr revid: tde@openerp.com-20120911115238-4r0oq2g5x4ffurde --- addons/sale/edi/sale_order_action_data.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/sale/edi/sale_order_action_data.xml b/addons/sale/edi/sale_order_action_data.xml index 49ebe6053e6..c818a3a22ab 100644 --- a/addons/sale/edi/sale_order_action_data.xml +++ b/addons/sale/edi/sale_order_action_data.xml @@ -47,7 +47,7 @@

Hello${object.partner_id.name and ' ' or ''}${object.partner_id.name or ''},

-

Here is your ${object.state in ('draft', 'sent') and 'quotation' or 'order confirmation'} from {$object.company_id.name}:

+

Here is your ${object.state in ('draft', 'sent') and 'quotation' or 'order confirmation'} from ${object.company_id.name}:

  REFERENCES
From 2a317c55fbada71e0f28f9ffc99a41d6780c0d1d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thibault=20Delavall=C3=A9e?= Date: Tue, 11 Sep 2012 13:59:47 +0200 Subject: [PATCH 4/5] [IMP] mail.compose.message wizard form view: put template field, and template buttons, as invisible. bzr revid: tde@openerp.com-20120911115947-rfjr8scrq06ni01s --- addons/email_template/wizard/mail_compose_message_view.xml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/addons/email_template/wizard/mail_compose_message_view.xml b/addons/email_template/wizard/mail_compose_message_view.xml index 96aaa1cfaae..8d5bc26b213 100644 --- a/addons/email_template/wizard/mail_compose_message_view.xml +++ b/addons/email_template/wizard/mail_compose_message_view.xml @@ -11,14 +11,14 @@