Skip to Content
Menu
This question has been flagged
3 Replies
2840 Views

Hello,

I'm running Odoo 8.

I tried to modify the invoice report to print move_lines.journal_id.name.

I have some invoices with multiples lines and i get an error:

Error:

File "/opt/odoo/odoo8/openerp/models.py", line 5320, in ensure_one
    raise except_orm("ValueError", "Expected singleton: %s" % self)
QWebException: "ValueError
Expected singleton: account.move.line(301, 299)" while evaluating
"translate_doc(doc_id, doc_model, 'partner_id.lang', 'account.report_invoice_document')"

Here is my modified report section:


<span t-if="o.move_lines.journal_id.name">
<strong>Payment method:</strong>
<t t-foreach="o.move_lines.journal_id" t-as="l">
<span t-field="l.name"/></t> <br/>
</span>
Any one can help me figure out why is not working?

Thank you very much

Avatar
Discard
Best Answer

Hello @ Patrizio Tafaro,

Your code:

wrong: <span t-if="o.move_lines.journal_id.name">
<strong>Payment method:</strong>
<t t-foreach="o.move_lines.journal_id" t-as="l">
<span t-field="l.name"/></t> <br/>
</span>

Note:  "move_lines" returns multiple records, you can not directly used in Report template. it is wrong so error face in system while print report.

"Expected singleton: account.move.line(301, 299)"

Solution:
<t t-foreach="o.move_lines" t-as="line">
    <span t-if="line.journal_id.name"/>
        <strong>Payment method:</strong>
        <span t-field="line.name"/>
</t>
Thank You.
Avatar
Discard
Best Answer

Hi,

Try with this code,


<t t-foreach="o.move_lines" t-as="ml">
<span t-if="ml.journal_id.name"/>
<strong>Payment method:</strong>
<span t-field="l.name"/>
</t>


Thanks

Avatar
Discard
Author Best Answer

Thank you @Dhaval you answer was super fine.

Now works fine!

Avatar
Discard
Related Posts Replies Views Activity
6
Jan 20
6957
0
Nov 15
2368
2
Aug 17
7713
1
Nov 16
3191
1
Aug 16
6540