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.


Filter products by selected supplier on purchase order

William Brugger
on 12/15/15, 12:04 AM 313 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

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

1 follower(s)


Asked: 12/15/15, 12:04 AM
Seen: 313 times
Last updated: 12/15/15, 1:47 AM