콘텐츠로 건너뛰기
메뉴
커뮤니티에 참여하려면 회원 가입을 하시기 바랍니다.
신고된 질문입니다
3 답글
3942 화면

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

아바타
취소
베스트 답변

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.
아바타
취소
베스트 답변

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

아바타
취소
작성자 베스트 답변

Thank you @Dhaval you answer was super fine.

Now works fine!

아바타
취소
관련 게시물 답글 화면 활동
6
1월 20
8264
0
11월 15
3227
2
8월 17
9259
1
11월 16
4582
1
8월 16
7823