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

i need to filter product which color is red & size is small 

self.env['product.template'].search([('name', '=', 'Product A"]),(attribuet_value,'=',''),], limit=1)

how i can search it ... any help

Ảnh đại diện
Huỷ bỏ

You have to learn basic customization in odoo: https://github.com/sehrishnaz/learnopenerp/wiki

Câu trả lời hay nhất

Hi Usman,

Try this code,

products = self.env['product.template'].search([('attribute_line_ids.attribute_id', '=', "Color Name"),('attribute_line_ids.value_ids', 'in', "Small")], limit=1)

If you know the ID of Color and Size, You can use it directly.

Thanks

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

Hi Usman,

Try this code.


products = self.env['product.product'].search([('name', '=', 'Product A'),
('attribute_value_ids.name', '=', 'red'),
('attribute_value_ids.name', '=', 'small')])

Thanks

Ảnh đại diện
Huỷ bỏ

searching with the name? Please Update your answer.

Hi Hilar

What is wrong in the search for the name?

What if the name is get changed? Do you update the code in live server with the name? The name field will not be a unique constraint, however. Think

Your point is good. and it is not a piece of new knowledge for me. We can't predefine what the end-users needs.

Right?

Good to hear from you. We should able to predefine the end-users needs anyway. That is the role of a coder.

Thank you for the valuable advice. Have a nice day

Bài viết liên quan Trả lời Lượt xem Hoạt động
0
thg 9 23
6316
1
thg 7 20
5078
3
thg 1 20
12822
0
thg 9 19
98
0
thg 12 23
8216