Odoo Help


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.


how to add records in many2many field?

on 3/26/15, 6:02 PM 2,866 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 = '';


       domains: [domain],

      contexts: [Mail.get_context()]

      }).done(function (result) {


         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;






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 ( ).

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)


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