Odoo Help

Welcome!

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.

0

Filter products by selected supplier on purchase order

By
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"

@api.onchange('partner_id')

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

self.env.cr.execute(query)

a = self.env.cr.fetchall()

d = 0

for i in a:

e = i[0]

sub_id.append(e)

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)

Stats

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