Skip to Content
เมนู
คุณต้องลงทะเบียนเพื่อโต้ตอบกับคอมมูนิตี้
คำถามนี้ถูกตั้งค่าสถานะ
1 ตอบกลับ
2657 มุมมอง

Hi,


I have a product (t-shirts) with different product_no_variant_attribute_value_ids like colors, sizes, styles, etc


I'm creating a report and need search and show only the products that have the product_no_variant_attribute_value_ids == 'COLOR', like this


X brand T-shirt -> blue

Y brand T-shirt -> red


The solution I've found is to loop through EVERY attribute of that product and see if it matches "COLOR", but there must be an easier way


My code:

⩽t t-foreach="doc.order_line" t-as="line"⩾
    ⩽t t-set="counter" t-value="0"⩾
    ⩽t t-foreach="line.product_no_variant_attribute_value_ids.attribute_id" t-as="attrib"⩾
        ⩽t t-if="attrib.name == 'COLOR'"⩾            
            ⩽span t-field="line.product_id.name"⩾
            ⩽span t-field="line.product_no_variant_attribute_value_ids.product_attribute_value_id[counter].name"⩾
        ⩽/t⩾
        ⩽t t-set="counter"\ t\-value="counter+1"⩾
    ⩽/t⩾
⩽/t⩾



How can I search if the product_no_variant_attribute_value_ids contains an attribute named color?





อวตาร
ละทิ้ง
ผู้เขียน คำตอบที่ดีที่สุด

Found it, the answer is:

line\.product_no_variant_attribute_value_ids\.filtered\(lambda\ x:\ x.attribute_id.name == 'COLOR').product_attribute_value_id.name

อวตาร
ละทิ้ง
Related Posts ตอบกลับ มุมมอง กิจกรรม
Remove Search Box on /shop page แก้ไขแล้ว
4
พ.ย. 23
3336
3
มี.ค. 21
6900
1
มี.ค. 15
6980
1
มี.ค. 15
6076
2
มี.ค. 24
1675