0

Req is i have created a Product called Product1 and i have given 2 attributes for that i.e. color,fitting,size.

I have defined a field in sale.order

product_id = fields.Many2one('product.product', string="Product")

As per the standard we are getting Product1(color,fitting,size)

My req is i need to get only one attribute i.e. Product1(color)

I tried to do override in name_get function it is not getting. Can anyone help?

Thanks in advance

iam supreeth
  • 497
  • 4
  • 16

1 Answers1

1

You need product name in sale_order product id field for that you have to override name_saerch method. In many2one field it always call name_search method. Thanx

Akshay
  • 639
  • 3
  • 8
  • thanks for the reply.. can you please help me out in tat? – iam supreeth Dec 28 '18 at 06:06
  • name_search method returns the name of the model.you can override name_search method and returns the name of the product according to your requirement . – Akshay Dec 30 '18 at 06:57
  • def name_search(self, name='', args=None, operator='ilike', limit=100): vehicle_name= super(Vehicle, self).name_search(name=name, args=args, operator=operator, limit=limit) args += [('vehicle_no', operator, name)] vehicles_no = self.env['fleet.vehicle'].search(args) for vehicle in vehicles_no: if (vehicle.id, vehicle.name) not in vehicle_name: vehicle_name.append((vehicle.id, vehicle.name)) return vehicle_name – Akshay Dec 30 '18 at 06:58
  • You can see in my example i added searching of vehicle according to vehicle_no also and return the whole vehicle name at last. It will also search vehicle no in it and it will get whole name of vehicle with vehicle no also.You also have to add or remove your colour or size in your ptoduct name so that in sale order page you will get your product name with size, colour or anything – Akshay Dec 30 '18 at 06:58