Skip to Content
Menu
This question has been flagged
1 Reply
22670 Views

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);

      });

});

});

}

Avatar
Discard
Author Best Answer


So if anyone needs that in .js, it is used like attachment_ids = [[ 6, 0, [1] ]] , please note with [ ] not ( ).

Avatar
Discard
Related Posts Replies Views Activity
4
Sep 15
4085
3
Aug 15
7514
2
Apr 23
28822
1
Mar 17
3006
0
Jun 16
3532