Reference node inherits taxonomy terms of referenced node This is a problem that's been bugging me for days now and haven't yet found a solution in Drupal 7. 

I'll be more specific:

I have a content type named Debate and another one called Vote. 
Vote type has a node reference field to Debate type. 

Debate type has a term reference field (autocomplete widget, 4 values, Voting choices vocabulary) where user inserts the voting choices of his Debate node. 

Vote type has a term reference field (select list, 1 value, Voting choices vocabulary) where user can choose a term to vote. 

My problem is that the select list of the term reference field of the Vote node shows all the terms of the Voting choices vocabulary. What I want is the select list of the Vote node to show only the terms that come from the Debate node it's referring to.

In other words I need to filter out the terms of the Vote node based on the Debate node it's referring to, when I'm at the node/add/Vote form of course.
First you would create a form alter function and make the taxonomy field as hidden and add ajax functionality to the node reference field. I am assuming that then node reference field widget is a select list.  

For the following example I am assuming your fields are in the Basic Page. you can change the function name to suite your requirement by changing the mymodulename and page.

I am assuming the field name of the term reference field is field_vote and the node reference field is field_debate

function mymodulename_form_page_node_form_alter(&amp;$form, &amp;$form_state, $form_id) {
  // We add the ajax functionality to the node reference field.
  $form['field_debate']['#ajax'] = array(
    // #ajax has two required keys: callback and wrapper.
    // 'callback' is a function that will be called when this element changes.
    'callback' =&gt; 'vote_field_return',
    // 'wrapper' is the HTML id of the page element that will be replaced.
    'wrapper' =&gt; 'replace_vote_div',
  );

  // Add a wrapper around the taxonomy field.
  $form['#prefix'] = '&lt;div id="replace_vote_div"&gt;';
  $form['#suffix'] = '&lt;/div&gt;';

  // Check the form state to see if the debate field is filled.
  if (!empty($form_state['values']['field_debate'])) {
    // Load the debate node.
    $debate = node_load($form_state['values']['field_debate']);

    $form['field_vote']['#type'] = 'select';

    // Assuming the taxonomy field in debate content type is field_vote_debate
    // Some times the language for the field might be different from the language of
    // the node itself in this case you might want to look at a dump of the $date
    // field and make the required changes. 
    foreach($debate-&gt;field_vote_debate['$debate-&gt;language'] as $vote_term) {
      $form['field_vote']['#options'][$vote_term['taxonomy_term']-&gt;tid] = $vote_term['taxonomy_term']-&gt;name;
    }
  }
  else {
    // Hide the taxonomy field to start of with.
    $form['field_vote']['#type'] = 'hidden';
  }
}


The call back function is pretty straight forward we simply return the field_vote so that it can be rendered again in the form

function vote_field_return($form, $form_state) {
  // The form has already been submitted and updated. We can return the replaced
  // item as it is.
  return $form['field_vote'];
}


Note: As per the comment Please find below the updated code if the node ID is coming from url

I am assuming that the url to add the vote node is as follows

http://example.com/node/add/vote/23

where 23 is the node ID of the debate content type. 

function mymodulename_form_vote_node_form_alter(&amp;$form, &amp;$form_state, $form_id) {
  // We use the arg() function to get the argument from the url. The numbering
  // starts from 0 and the one we need would be at 3. 
  $debate = node_load(arg(3));



  // Assuming the taxonomy field in debate content type is field_vote_debate.
  // Some times the language for the field might be different from the language of
  // the node itself in this case you might want to look at a dump of the $date
  // field and make the required changes. 

  foreach($debate-&gt;field_please_vote['$debate-&gt;language'] as $vote_term) {
    $term = taxonomy_term_load($vote_term['tid']); 
    $form['field_vote']['und']['#options'][$vote_term['tid']] = $term-&gt;name;
  }  
}