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

I customized the "external_layout_header" template from the "report" module in a custom module that modifies the Sales Quote/Order layout.  I didn't realize that this template is also used for Purchase RFQs/Orders.  Now I'm getting errors on the Purchase Order layout, because I moved a field from the sale.order object up into the header template, and this field doesn't exist in the purchase.order object.  Is there any way that I can detect the document/object type with a t-function?  Something along the lines of <t t-if="o = 'sale.order'"> ...?

อวตาร
ละทิ้ง
คำตอบที่ดีที่สุด

Try this:

<t t-if="doc_model == 'sale.order'">

Available variables, see: QWeb Reports documentation

อวตาร
ละทิ้ง
ผู้เขียน

Cool. I will try that, thanks! I couldn't find any information on what kinds of comparisons can be done inside of a t-if statement. Is there any documentation for methods and operators?

ผู้เขียน

Or the available variables, such as the "doc_model" you listed?

Updated my answer.

ผู้เขียน

Thanks. I had read the QWeb section, but didn't notice that there was a separate QWeb Reports section.

Thank you very much for the answer. I spent so many hours fixing my problem before find this forum.

My code was:
<div t-if="o._name == 'sale.order'">

So I obtained odoo error:
AttributeError: 'NoneType' object has no attribute '_name'

you change the code like this. it will work
<div>
<t- t-if="o._name == 'sale.order'">
</t>
</div>

Related Posts ตอบกลับ มุมมอง กิจกรรม
1
ก.ค. 16
24405
2
มี.ค. 15
7556
QWEB: Place full width image on page แก้ไขแล้ว
1
มิ.ย. 21
8013
0
มี.ค. 15
3749
1
มี.ค. 15
14165