تخطي للذهاب إلى المحتوى
القائمة
لقد تم الإبلاغ عن هذا السؤال
1 الرد
3257 أدوات العرض

I have a list here and I trying to mapped the brand field. May I know how can I mapped this appended list?
Ex.[Chanel, Vuitton, Vuitton, Celine]
 I wanted Vuitton returned 1 data only



 ai_list = []
        for ai in ai_record:
            for ail in ai.invoice_line_ids:
                ai_list.append({  'partner_id': partner_id.name,
                                  'transaction_date': ai.date_invoice, 
                                  'invoice_number': ai.number, 
                                  'brand': ai.brand, // how to use mapped() here
                                  'net_value': ai.residual, })
        return ai_list    


الصورة الرمزية
إهمال

#python #for #odoo #customization

https://old.reddit.com/r/PythonForOdoo/

أفضل إجابة

Hi,

Try this,
ai_list = []
for ai in ai_record:
    brand = list(set(ai.brand))
    for ail in ai.invoice_line_ids:
        ai_list.append({ 'partner_id': partner_id.name,
                'transaction_date': ai.date_invoice,
                'invoice_number': ai.number,
                'brand': brand,
                'net_value': ai.residual, })
return ai_list

Check this link too https://www.w3schools.com/python/python_sets.asp 

Hope it helps,

Thanks

الصورة الرمزية
إهمال
المنشورات ذات الصلة الردود أدوات العرض النشاط
0
ديسمبر 24
1006
2
يونيو 23
2530
1
يناير 23
2679
1
أكتوبر 20
4307
4
يوليو 17
7257