title: How to apply domain filter on Many2One field Using Odoo JS?
body: <p>Currently, I am Working on <strong>POS Customization</strong>. I've done almost but stuck in this issue. </p>
  
  <p><strong>Py File:</strong></p>
  
  <pre><code>class prescription(osv.osv):
  
       _name = 'res.prescriptions'
  
       _columns={
  
           'prescription_id':fields.many2one('res.partner',"customer"),
  
        }
  
  class prescription_res_partner(osv.osv):
  
      _inherit = 'res.partner'
  
      _columns = {
  
          'prescriptions_ids':   fields.one2many('res.prescriptions','prescription_id','Prescriptions'),
  
  }
  </code></pre>
  
  <p>What I would like to do, is that when the user <strong>select customer</strong> in POS, and <strong>click</strong> on <strong>Prescription Button</strong>, it shows only prescriptions that are related to particular <strong>selected customer</strong>.. For now, it displays all prescriptions as I am not able to set correctly the filter domain. Also.....</p>
  
  <p>i've tried to solve my problem using <strong>.query()</strong>, <strong>.filter()</strong> in <strong>JS</strong>. but getting some errors, while if i put static partner_id then it will display prescriptions for given static partner_id. I want to solve this for dynamic partners. it shows only selected partner's prescriptions...!!!</p>
  
  <p><strong>In JS File:</strong> </p>
  
  <pre><code>var def = new $.Deferred();
  
  console.log("deffffffffffffff", def);
  
  var fields = _.find(this.models,function(model){ return model.model === 'res.prescriptions'; });
  
  new instance.web.Model('res.prescriptions')
  
     .query(fields)
  
     .filter([['prescription_id', '=', 51]]) // Here i pass static partner_id instead of this i want to pass dynamic partner_id
  
     .limit(1000)
  
     .all()
  
     .then(function(prescriptions){
  
  if (self.render_list_prescription(prescriptions)) { // Render selected partner's Prescription
  
      def.resolve();
  
      } else {
  
      def.reject();
  
      }
  
      }, function(err,event){ event.preventDefault(); def.reject(); });
  
  return def;
  </code></pre>
  
  <p>i've spend almost 3 days to overcome this problem but failed to Deliver it. please help me out from this. Again Many Thanks for your help..!!!</p>