I am launching a wizard (mail.message.compose) using .js and want to pre fill some fields at launch of wizard. many2many fields are not prefilled using attachment_ids = [( 6, 0, [1])], many2one, char and selection fields are working fine.
I am doing something like ..
function launch_wizard(self, view, user_type, email) {
var action = view.getParent().action;
var Mail = new session.web.DataSet(self, 'mail.compose.message', view.dataset.get_context());
var domain = new session.web.CompoundDomain(view.dataset.domain);
if (view.fields_view.type == 'form') {
domain = new session.web.CompoundDomain(domain, [['id', '=', view.datarecord.id]]);
}
if (view.fields_view.type == 'form') rec_name = view.datarecord.name;
else rec_name = '';
session.web.pyeval.eval_domains_and_contexts({
domains: [domain],
contexts: [Mail.get_context()]
}).done(function (result) {
Mail.create({
subject: action.name,
record_name: rec_name,
composition_mode: 'comment',
attachment_ids = [( 6, 0, [1])], writing it here directly for removing complications of computing attachment ids
}).done(function(mail_id) {
var step1 = Mail.call('go_step_1', [[mail_id], Mail.get_context()]).done(function(result) {
var action = result;
self.do_action(action);
});
});
});
}