简体   繁体   English

在Odoo中如何写if

[英]How to write if in Odoo

I'm trying to edit the xml of Odoo POS receipt, I'm going to add the following If TAX no.我正在尝试编辑 Odoo POS 收据的 xml,如果 TAX 没有,我将添加以下内容。 feild of the customer is filled in, then write it (on the receipt)填写客户的字段,然后写上(在收据上)

I wrote this我写了这个

<t t-if='receipt.client'>
<div>------------****--------------</div>
<div>Customer</div>
<div><t t-esc="env.pos.get_client().name"/></div>
<div>TAX ID:<t t-esc="receipt.client.vat"/></div>
<div><t t-esc="receipt.client.street"/> <t t-esc="receipt.client.street2"/> - <t t-esc="receipt.client.city"/><t t-esc="receipt.client.state_id"/></div>
</t>

So.. when I didn't fill in TAX feild, I expected t-if in the begining will do the function. But the result was (VAT ID: False).所以.. 当我没有填写 TAX 字段时,我希望t-if在开始时会执行 function。但结果是(VAT ID:False)。 The same with street and street2 I want to write if for all the above data.与 street 和 street2 相同,我想为上述所有数据编写 if 。 Any help please?有什么帮助吗?

I suugested that for myself我自己建议

<t t-if='receipt.client'>
<div>------------****--------------</div>
<div>بيانات العميل</div>
<div><t t-esc="env.pos.get_client().name"/></div>
<t t-if="receipt.client.vat"> <div>TAX ID:&#160;<t t-esc="receipt.client.vat"/></div>
</t>
<t t-if="receipt.client.street">
<div>address:&#160;<t t-esc="receipt.client.street"/></div>
</t> 
<t t-if="receipt.client.street2"><t t-esc="receipt.client.street2"/></t>
<t t-if="receipt.client.city"><t t-esc="receipt.client.city"/></t>
<t t-if="receipt.client.state_id"><t t-esc="receipt.client.state_id"/></t> </t>

was that correct?那是对的吗?

Did you inherit the template correctly?您是否正确继承了模板? It should be enclosed in something like the following:它应该包含在如下内容中:

<template id="insert_your_template_id" inherit_id="module.template_you_are_inheriting">

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM