简体   繁体   中英

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. 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). The same with street and street2 I want to write if for all the above data. 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">

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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