İçereği Atla
Menü
Bu soru işaretlendi
2 Cevaplar
2925 Görünümler

Greetings,

i want to change the domain of many2one field to present new records , the code worked fine but with wrong values

after i invoke the function : the values first will present the comanies name and if i click on one company , the values which i want (customer names ) will appeare .

how i can remove the first list which is the locations ? and from where this values retrieved i don't know .

 

My Code :

#------------PY

'customer_name':fields.many2one('res.partner'),

#------------XML

<field name="customer_name" widget="selection"/>

#---------- Function

cus_array=[]

        myobj = self.pool.get('res.partner')
        ids = myobj.search(cr, uid, [])
        for id in ids:
            customer = self.pool.get('res.partner').browse(cr, uid, [id], {})            
            if customer.country_id.id == customer_country:
                cus_array.append(str(customer.name))
                               
        return {'domain':{'customer_name':[('name','=',cus_array)]}}

Avatar
Vazgeç
En İyi Yanıt

I would advise you to read the answer to this question: https://www.odoo.com/forum/help-1/question/best-practices-as-to-when-to-use-fields-selection-vs-fields-many2one-69262.

You cannot dynamically domain a many2one field with widget="selection".

Avatar
Vazgeç
Üretici En İyi Yanıt

well done thats worked for me ^____________^

 

Avatar
Vazgeç