[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
This commit is contained in:
parent
d8998dd2d4
commit
e089d49703
|
@ -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 = {
|
||||
|
|
|
@ -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'));
|
||||
},
|
||||
});
|
||||
|
|
|
@ -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',
|
||||
|
|
Loading…
Reference in New Issue