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.


domain many2one

Badache Zoubir
on 9/27/16, 11:55 AM 111 views

how to change the domain many2one when changing field Selection?

use domain on the many2one field in xml file that code something like

domain="[('key', '=', selection_fields)]" but you need to some relation between selection field and many2one fields.

i give one example:

<field string="Vendor" name="partner_id" domain="[('supplier', '=', True)]"/>

Jitendra Prajapati (jpr)
on 9/28/16, 3:15 AM

Bejaoui Souheil

--Bejaoui Souheil--
| 2 1 4
Sousse, Tunisia
--Bejaoui Souheil--

Odoo developer,  functional and technical consultant


Bejaoui Souheil
On 9/28/16, 3:55 AM


If you have to set a domain on field if a value of an other field is changed, set an onchange method like this:

def do_stuff(self):
    return {'domain':[Your domain]}

    # Here you can call field selection by using self.selection

Best regards

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

2 follower(s)


Asked: 9/27/16, 11:55 AM
Seen: 111 times
Last updated: 9/28/16, 3:55 AM