Odoo Help

Welcome!

This community is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

1

how to add records in many2many field?

By
Yogesh
on 3/26/15, 6:02 PM 2,877 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);

      });

});

});

}

1
Yogesh
On 3/27/15, 6:33 PM


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

0
John
On 3/27/15, 6:27 PM

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

1 follower(s)

Stats

Asked: 3/26/15, 6:02 PM
Seen: 2877 times
Last updated: 3/27/15, 6:44 PM