Odoo Help


How to apply domain filter on Many2One field Using Odoo JS?

Ayaz Mansuri
on 3/8/16, 2:58 AM 3,145 views

Hello Community...!!!

Currently, I am Working on POS Customization. I've done almost but stuck in this issue. 

Py File:

class prescription(osv.osv):

_name = 'res.prescriptions'




class prescription_res_partner(osv.osv):

_inherit = 'res.partner'

_columns = {

'prescriptions_ids': fields.one2many('res.prescriptions','prescription_id','Prescriptions'),


What I would like to do, is that when the user select customer in POS, and click on Prescription Button, it shows only prescriptions that are related to particular selected customer.. For now, it displays all prescriptions as I am not able to set correctly the filter domain. Also.....

i've tried to solve my problem using .query(), .filter() in JS. 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...!!!

In JS File: 

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')


.filter([['prescription_id', '=', 51]]) // Here i pass static partner_id instead of this i want to pass dynamic partner_id




if (self.render_list_prescription(prescriptions)) { // Render selected partner's Prescription


} else {



}, function(err,event){ event.preventDefault(); def.reject(); });

return def;

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..!!!

Thanh Loyal
On 3/8/16, 5:24 AM


The first thing is in your prescription class, the field name should be customer_id instead of 'prescription_id'

And about current customer: My case, i call this from inside a Widget:

var client = this.pos_widget.clientlist_screen.new_client;

if it is not your case, search for 'clientlist_screen' in source code of point_of_sale module, you'll see it.

Hope this help.

Ya i know its a Mistake that field name should be customer_id or partner_id. but it doesn't matter at all. i just want to know that how can i filter dynamic partner_id & shows only selected partner's prescriptions. Thanks

Ayaz Mansuri
on 3/8/16, 5:35 AM

About This Community

This platform 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.


Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now

Question tools

1 follower(s)


Asked: 3/8/16, 2:58 AM
Seen: 3145 times
Last updated: 4/1/16, 6:49 AM