Search code examples
pythonxmlodoohelper

How can I implement this function in Odoo 12 or OpenERP?


I'm trying to make a conditional function for the invoices. I know how to write but I don't know how can I implement in Odoo by code.

My function

if(country_id==base.au || country_id==base.ca || country_id==base.jp || country_id==base.li)
{
   <t t-if="o.emb_confirm_message == True">
       <strong><th t-field="o.emb_message"/></strong>
   </t>
}

When the invoice has any of does countries a message will appear on the report. How can I implement this function in Odoo 12? Thanks


Solution

  • I'm not a fan of too much code in QWeb templates, but this should work:

    <t t-set="is_for_emb_message_country"
        t-value="o.partner_id.country_id.id in [o.env.ref('base.au').id, o.env.ref('base.ca').id, o.env.ref('base.jp').id, o.env.ref('base.li').id]" />
    <t t-if="o.emb_confirm_message is True and is_for_emb_message_country">
           <strong><th t-field="o.emb_message"/></strong>
    </t>