Odoo Help

0

Filter products by selected supplier on purchase order

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

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.

Register

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)

Stats

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