How to get a field from another module on create view?

Hi everyone,

I have the next requirement, I need to get a field from a no related module and set the value of this field on the name field when I'm creating a new record. For example, in a custom module, we have a field called "consecutive", when we are creating a new opportunity we want to show the consecutive value (from our custom module) on the name field. 

  • I do this to copy some data from the Accounts module to the Opportunity when an Opportunity is created from the subpanel on Accounts.

    This code is part of my 

    custom/modules/Opportunities/clients/base/views/create/create.js

    I check to see if the parent is an Account, if so, I copy the data if the values are there.

    render: function()
       {
          this._super('render');
          //if coming from Account
          if(typeof(parent_record) !== 'undefined' && parent_record.get('module') == 'Accounts') this.setFromAccount();
       }, 
       setFromAccount: function(){
         var parent_record = this.context.parent,
             parent_affiliation = typeof(parent_record.get('model').get('affiliation_c')) == 'undefined'?'':parent_record.get('model').get('affiliation_c'),
             parent_acad_subtype = typeof(parent_record.get('model').get('academic_subtype_c')) == 'undefined'?'':parent_record.get('model').get('academic_subtype_c');
         this.model.set('affiliation_c',parent_affiliation); //a simple set statement takes care of selecting the option on the dropdown
         this.model.set('academic_subtype_c', parent_acad_subtype);
       },

    Hope this helps.

    Francesca