This question has been flagged
1 Reply
4678 Views

i am created new field brand in product,how can i display the brand name when selecting a product in sales order form

Avatar
Discard
Best Answer

Hi,

You can achieve this by overwriting name_get method of product.

You just need to inherit the Product class and add below method.

def name_get(self, cr, uid, ids, context=None):
    if not len(ids):
        return []
    res = []
    product_read = self.read(cr, uid, ids, ['name', 'default_code' ,'brand'], context=context)
    for product in product_read:
        name = ''
        if product.get('default_code',False):
            name='['+product.get('default_code')+'] '

        if product.get('brand',False):
            name+='['+product.get('brand')+'] '

        name+=product.get('name',False)
        res.append((product['id'], name))
    return res

Above is just an example, you can customize and add values based on requirements.

Thanks,
www.acespritech.com

Avatar
Discard