Odoo Help


Filter products by selected supplier on purchase order

William Brugger
on 12/15/15, 12:04 AM 734 views

I am using this but the domain is not being passed to the field.  As I understand in the newest API, it is not necessary to add the function call to the xml file.  Any help would be appreciated.

from openerp import models, fields, api

class kco_supplier_filter(models.Model):

_inherit = "purchase.order"


def onchange_partner(self):

res = {}

if self.partner_id:

sub_id =[]

a = []

partner = self.partner_id.id 

query = """SELECT Distinct(product_product.id) FROM public.product_supplierinfo,public.product_product WHERE product_supplierinfo.product_tmpl_id = product_product.product_tmpl_id and product_supplierinfo.name = %s""" % partner


a = self.env.cr.fetchall()

d = 0

for i in a:

e = i[0]


d += 1

res = {

'domain': {'product_id': [('id', 'in', sub_id)]},


return res

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: 12/15/15, 12:04 AM
Seen: 734 times
Last updated: 12/15/15, 1:47 AM