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

Hi,

Currently I am doing this

 <tbody>
<t t-foreach="get_payslip_lines(o.line_ids)" t-as="p">
<tr>
<t t-if="p.code == 'BASIC' or p.code == 'GROSS' or p.code == 'NET' or p.code == 'TOTAL' ">
<td><b><span t-field="p.code"/></b></td>
<td><b><span t-field="p.name"/></b></td>
<!-- <td><span t-field="p.quantity"/></td> -->
<td><b><span t-esc="formatLang(p.amount, currency_obj=o.company_id.currency_id)"/></b></td>
<td><b><span t-esc="formatLang(p.total, currency_obj=o.company_id.currency_id)"/></b></td>
</t>
<t t-if="p.code != 'BASIC' and p.code != 'GROSS' and p.code != 'NET' and p.code != 'TOTAL' ">
<td><span t-field="p.code"/></td>
<td><span t-field="p.name"/></td>
<!-- <td><span t-field="p.quantity"/></td> -->
<td><span t-esc="formatLang(p.amount, currency_obj=o.company_id.currency_id)"/></td>
<td><span t-esc="formatLang(p.total, currency_obj=o.company_id.currency_id)"/></td>
</t>
</tr>
</t>
</tbody>


I tried to search there isn't an example on Qweb's if else example.





الصورة الرمزية
إهمال
أفضل إجابة

Hello,

Generally we use ,

<t t-if="p.code == 'BASIC'">

    executable statement..

</t>

for false condition,

<t t-if="not p.code == 'BASIC'">

    executable statement..

</t>

Regards,

الصورة الرمزية
إهمال
الكاتب

Thanks. How, this solution doesn't seem much difference to my except you use "not" to negate the condition. I still have to specify the list of conditions to do that.

أفضل إجابة

hi

this is my invoice Report.In this Report if condition available if amount to text filed is yes then it's print  amount to text in report and if no then condition false so, it's not print.


<?xml version="1.0" encoding="utf-8"?>

<openerp>

<data>

<template id="report_invoice_document_inherit" inherit_id="account.report_invoice_document">

<xpath expr="//p[@t-if='o.fiscal_position']" position="after">

<p>

<span t-if="o.amount_text_need == 'yes'">

<!--<span t-if="o.currency_id == '21'">-->

<strong>Amount in Word:</strong>

<span t-esc="o.amount_to_text(o.amount_total, 'USD')"/></span>

</p>

</xpath>

</template>

</data>

</openerp>



and in your code

if condition is

<t t-if="p.code == 'BASIC' or p.code == 'GROSS' or p.code == 'NET' or p.code == 'TOTAL' "> 

الصورة الرمزية
إهمال
الكاتب

Thanks. if you read my code, what I am trying to achieve is to bold Basic,Gross,Net and Total, and leave the rest unbold.

first you have to check p.code value is coming from print p.code value in report and see what actually values are come.

الكاتب

that is what my code is doing and works, but that I need a more elegant way for doing conditions.

الكاتب أفضل إجابة

This post is already marked resolved.
Sorry to be rude. I can't understand people replying me here didn't even read and understand my question and posting me useless(sorry again to be blunt) suggestion.

Please read again. My question is asking if there is a else conditional instead of me negating my previous condition(s).

Anyway again. This post is closed. Please do not answer. And I stopped using Odoo already. Thank you


الصورة الرمزية
إهمال
أفضل إجابة

Dear it is the same conndition test of python 

الصورة الرمزية
إهمال
أفضل إجابة

how to create custom reports in odoo using qweb reporting engine. In this post we will learn how to create simple custom reports and its template.

  1. http://learnopenerp.blogspot.com/2016/09/how-to-create-custom-reports-in-odoo.html

  2. http://learnopenerp.blogspot.com/2016/11/how-to-create-qweb-reports-in-openerp.html

الصورة الرمزية
إهمال
المنشورات ذات الصلة الردود أدوات العرض النشاط
1
سبتمبر 21
9464
1
يونيو 16
7137
1
يوليو 25
1661
1
مايو 25
1631
1
أبريل 25
2239