Odoo Help


Two Modules Colliding - Need Help (v7)

Alex Gallien
on 6/29/15, 7:48 PM 704 views

I really am at my wit's end here. I have two modules (purchase_control_supplier and search_product_supplier_code) that I want to have running at the same time, and they appear to be incompatible. If I have search_product_supplier_code installed, purchase_control_supplier stops working without fail. I think that it may have something to do with the fact that purchase_control_supplier modifies the search() function, which is called in the name_search() function that search_product_supplier_code uses. Any idea how to fix this? Nothing stands out to me immediately as being wrong. Including the code below


from osv import osv, fields
class product_product(osv.osv):
_name = 'product.product'
_inherit = 'product.product'
def name_search(self, cr, user, name, args=None, operator='ilike', context=None, limit=100):
if name:
if args:
args = ['|', ('suppliers_code', operator, '%' + name + '%')] + args
args = ['|', ('suppliers_code', operator, '%' + name + '%')]
res = super(product_product,self).name_search(cr, user, name, args, operator='ilike', context=None, limit=100)
return res
def _suppliers_code(self, cr, uid, ids, name, arg, context=None):
res = {}
prds = self.browse(cr, uid, ids)
for prd in prds:
code = ''
for line in prd.seller_ids:
code = '%s %s' % (code, line.product_code)
res[prd.id] = code
return res
_columns = {
'suppliers_code': fields.function(_suppliers_code, type='char', size=256, string='Supplier Code', store=True),


from osv import osv, fields
class product_product(osv.osv):
_name = "product.product"
_inherit = "product.product"
def search(self, cr, uid, args, offset=0, limit=None, order=None, context=None, count=False):
if context and context.get('supplier_id', False):
product_limit = self.pool.get('res.partner').read(cr,uid,context['supplier_id'],['supplier_product_limit'])['supplier_product_limit']
if product_limit:
# ids = []
cr.execute("SELECT distinct(product_id) FROM product_supplierinfo where name = %s" % (context.get('supplier_id')))
ids = [x[0] for x in cr.fetchall()]
args.append(('id', 'in', ids))
order = 'default_code'
return super(product_product, self).search(cr, uid, args, offset=offset, limit=limit, order=order, context=context, count=count)
class res_partner(osv.osv):
_name = 'res.partner'
_inherit = 'res.partner'
_columns = {
'supplier_product_limit':fields.boolean("Control Supplier Search", help="""If checked, allows you to search only the product in this supplier )"""),
_defaults = {
'supplier_product_limit': True,

Any help would be greatly appreciated!

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: 6/29/15, 7:48 PM
Seen: 704 times
Last updated: 6/29/15, 7:48 PM