Bỏ qua để đến Nội dung
Menu
Câu hỏi này đã bị gắn cờ
1 Trả lời
4429 Lượt xem

Hi all,

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

Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất

Hello

into object product.attribute.value check method _variant_name.

i have make some modification into method. you can check that.  this below code will affect everywhere into the system wherever the product name is display with attribute. i hope this will helps you.

@api.multi
def _variant_name(self, variable_attributes):
    return ", ".join([v.name for v in self if (v.attribute_id in variable_attributes and v.attribute_id.name == 'Color')])
 
Ảnh đại diện
Huỷ bỏ
Tác giả

hi, thanks for the reply.. if we apply this method it will affects everywhere, but i need this condition only in sale.order

for that from sale.order.line's product_id field pass the context and that passed context you can get into this method. after that you can checked that context into the above method. that way you can achieve this.

Bài viết liên quan Trả lời Lượt xem Hoạt động
1
thg 10 22
8124
2
thg 5 24
2701
2
thg 1 23
4191
0
thg 1 21
2095
0
thg 6 19
2680