Follow @aasimansari
This post will help in creating many2one field whose value changes when the content of another field changes.
Lets consider a simple example. Suppose we have a many2one field to Product (name: product_id). We now want to change the content on this many2one field based on type selection box(name: type). Now, if I choose type as Service, only service type product should be visible in Product field.
To accomplish this, we have to define on change function on type selection box.
def onchange_type(self,cr,uid,ids, type,context=None):
product_obj = self.pool.get('product.product')
product_ids = product_obj.search(cr,uid, [('type','=',type)])
return {'domain':{'product_id':[('id','in',product_ids)]}}
Reblogged this on Apagen Solutions' Blog.
Hai, am a beginner in openerp(odoo). i like to learn odoo. can you help me?
how to implement the same in odoo8
it is not working in odoo8
Can you explain me what you are trying to achieve?
Hello, i am trying to modify the ‘internal reference’ (default_code) of a product so that when i start typing, it displays a list of existing references that start with what i have already typed? Can this be done? I assume i have to define the onchange, but as i’m a beginner with odoo, i have no idea what to write in it. Thank you
You have to use many2one field for it. You can study from doc.odoo.com
thanks a lot, i need this solution. Thanks from México
Thanks for the info