1
from osv import osv, fields
4
class Product(osv.osv):
5
_inherit = 'product.product'
7
def _partner_ref2(self, cursor, user, ids, name, arg, context=None):
9
for product in self.browse(cursor, user, ids, context=context):
10
res[product.id] = '\n'.join([x.product_code \
11
for x in product.seller_ids if x.product_code]) or ''
14
def _partner_ref2_search(self, cursor, user, obj, name, args):
15
supplierinfo_obj = self.pool.get('product.supplierinfo')
19
args[i] = ('product_code', args[i][1], args[i][2])
21
supplierinfo_ids = supplierinfo_obj.search(cursor, user, args)
22
product_ids = [ x.product_id.id for x in supplierinfo_obj.browse(cursor, user,
23
supplierinfo_ids) if x.product_id]
24
return [('id', 'in', product_ids)]
27
'partner_ref2': fields.function(_partner_ref2, method=True,
28
type='char', string='Customer ref', fnct_search=_partner_ref2_search,
32
def name_search(self, cursor, user, name='', args=None, operator='ilike',
33
context=None, limit=80):
34
ids = self.search(cursor, user, [('partner_ref2', '=', name)] + args,
35
limit=limit, context=context)
37
return self.name_get(cursor, user, ids, context=context)
38
return super(Product, self).name_search(cursor, user, name=name, args=args,
39
operator=operator, context=context, limit=limit)