This question has been flagged
2 Replies
3317 Views

I'm using odoo version 9 and I've created a module to customize the reports of the vendor command strip. Among the fields that I want displayed in the reports is the supplier reference for article but when I add the code that displays this field <span> <t t-esc="', '.join([str(x.product_code) for x in o.order_line.product_id.product_tmpl_id.seller_ids])"/>but it displays an error when I want to start printing the report 
QWebException: "Expected singleton: purchase.order.line(57, 58, 59, 60, 61, 62, 63, 64)" while evaluating "', '.join([str(x.product_code) for x in o.order_line.product_id.product_tmpl_id.seller_ids])"

PS: I don't change anything in the module purchase. I don't know how to fix this problem any idea for help please ?

Avatar
Discard
Best Answer

Hi Dhouha,

First you need to loop for lines and then go for seller.

Ex:

<t t-foreach="o.order_line" t-as="line">
    <span> <t t-esc="', '.join([str(x.product_code) for x in line.product_id.product_tmpl_id.seller_ids])"/>
</t>
Avatar
Discard
Best Answer

It is because you use o.order_line that has many lines but you directly call o.order_line.product_id.product_tmpl_id.seller_ids.  So, you have to make looping for o.order_line first. or if you want to test with only one order line record please use o.order_line[0].product_id.product_tmpl_id.seller_ids

Avatar
Discard