Skip to Content
Odoo Menu
  • Prijavi
  • Try it free
  • Aplikacije
    Finance
    • Knjigovodstvo
    • Obračun
    • Stroški
    • Spreadsheet (BI)
    • Dokumenti
    • Podpisovanje
    Prodaja
    • CRM
    • Prodaja
    • POS Shop
    • POS Restaurant
    • Naročnine
    • Najem
    Spletne strani
    • Website Builder
    • Spletna trgovina
    • Blog
    • Forum
    • Pogovor v živo
    • eUčenje
    Dobavna veriga
    • Zaloga
    • Proizvodnja
    • PLM
    • Nabava
    • Vzdrževanje
    • Kakovost
    Kadri
    • Kadri
    • Kadrovanje
    • Odsotnost
    • Ocenjevanja
    • Priporočila
    • Vozni park
    Marketing
    • Družbeno Trženje
    • Email Marketing
    • SMS Marketing
    • Dogodki
    • Avtomatizacija trženja
    • Ankete
    Storitve
    • Projekt
    • Časovnice
    • Storitve na terenu
    • Služba za pomoč
    • Načrtovanje
    • Termini
    Produktivnost
    • Razprave
    • Odobritve
    • IoT
    • Voip
    • Znanje
    • WhatsApp
    Third party apps Odoo Studio Odoo Cloud Platform
  • Industrije
    Trgovina na drobno
    • Book Store
    • Trgovina z oblačili
    • Trgovina s pohištvom
    • Grocery Store
    • Trgovina s strojno opremo računalnikov
    • Trgovina z igračami
    Food & Hospitality
    • Bar and Pub
    • Restavracija
    • Hitra hrana
    • Guest House
    • Beverage Distributor
    • Hotel
    Nepremičnine
    • Real Estate Agency
    • Arhitekturno podjetje
    • Gradbeništvo
    • Estate Management
    • Vrtnarjenje
    • Združenje lastnikov nepremičnin
    Svetovanje
    • Računovodsko podjetje
    • Odoo Partner
    • Marketinška agencija
    • Law firm
    • Pridobivanje talentov
    • Audit & Certification
    Proizvodnja
    • Tekstil
    • Metal
    • Pohištvo
    • Hrana
    • Brewery
    • Poslovna darila
    Health & Fitness
    • Športni klub
    • Trgovina z očali
    • Fitnes center
    • Wellness Practitioners
    • Lekarna
    • Frizerski salon
    Trades
    • Handyman
    • IT Hardware & Support
    • Sistemi sončne energije
    • Izdelovalec čevljev
    • Čistilne storitve
    • HVAC Services
    Ostali
    • Neprofitna organizacija
    • Agencija za okolje
    • Najem oglasnih panojev
    • Fotografija
    • Najem koles
    • Prodajalec programske opreme
    Browse all Industries
  • Skupnost
    Learn
    • Tutorials
    • Dokumentacija
    • Certifikati
    • Šolanje
    • Blog
    • Podcast
    Empower Education
    • Education Program
    • Scale Up! Business Game
    • Visit Odoo
    Get the Software
    • Prenesi
    • Compare Editions
    • Releases
    Collaborate
    • Github
    • Forum
    • Dogodki
    • Prevodi
    • Become a Partner
    • Services for Partners
    • Register your Accounting Firm
    Get Services
    • Find a Partner
    • Find an Accountant
    • Meet an advisor
    • Implementation Services
    • Sklici kupca
    • Podpora
    • Upgrades
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Get a demo
  • Določanje cen
  • Pomoč

Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:

  • CRM
  • e-Commerce
  • Knjigovodstvo
  • Zaloga
  • PoS
  • Projekt
  • MRP
All apps
You need to be registered to interact with the community.
All Posts People Badges
Ključne besede (View all)
odoo accounting v14 pos v15
About this forum
You need to be registered to interact with the community.
All Posts People Badges
Ključne besede (View all)
odoo accounting v14 pos v15
About this forum
Pomoč

templating: t-if for string length

Naroči se

Get notified when there's activity on this post

This question has been flagged
templateskanbant-if
2 Odgovori
11025 Prikazi
Avatar
Alexander Soare

I want to display an origin ('City A') and destination ('City B') in a kanban template. These are both char fields in my model. I want to bit an arrow '→' between them but only if both are specified. This is a piece of my code:

<span>

<field name="x_quote_pickup_city"/>

<span t-if="x_quote_pickup_city != '' and x_quote_delivery_city != ''"> → </span>

<field name="x_quote_delivery_city"/>

<field name="x_quote_value"/>

</span>

The t-if doesn't seem to be working. This attempt just gives me the '→' even if the chars aren't set.

How would I go about achieving my goal here?

0
Avatar
Opusti
Avatar
Celia
Best Answer

Try to do this: 

<field name="x_quote_pickup_city"/> <field name="x_quote_delivery_city"/>     <field name="x_quote_value"/>

<span t-if="x_quote_pickup_city.raw_value and x_quote_delivery_city.raw_value">

    <t t-raw="x_quote_pickup_city.raw_value"/> →

    <t t-raw="x_quote_delivery_city.raw_value"/> </span>

I hope this works

1
Avatar
Opusti
Avatar
Alexander Soare
Avtor Best Answer

@Celia, I tried and get the following error message upon reloading the page:

Uncaught TypeError: Cannot read property 'raw_value' of undefined

https://erp.ontruck.io/web?debug#view_type=kanban&model=crm.lead&action=146&active_id=3:46

Traceback:

TypeError: Cannot read property 'raw_value' of undefined

at Engine.eval (eval at <anonymous> (https://erp.ontruck.io/web/static/lib/qweb/qweb2.js:402:33), <anonymous>:46:33)

at Engine.QWeb2.Engine.QWeb2.tools.extend._render (https://erp.ontruck.io/web/static/lib/qweb/qweb2.js:391:58)

at Engine.QWeb2.Engine.QWeb2.tools.extend.render (https://erp.ontruck.io/web/static/lib/qweb/qweb2.js:383:26)

at Engine.QWeb2.Engine.QWeb2.tools.extend._render (https://erp.ontruck.io/web/static/lib/qweb/qweb2.js:413:29)

at Engine.QWeb2.Engine.QWeb2.tools.extend.render (https://erp.ontruck.io/web/static/lib/qweb/qweb2.js:383:26)

at OdooClass.Widget.extend.init_content (https://erp.ontruck.io/web_kanban/static/src/js/kanban_record.js:67:34)

at OdooClass.Widget.extend.init (https://erp.ontruck.io/web_kanban/static/src/js/kanban_record.js:42:14)

at OdooClass.prototype.(anonymous function) [as init] (https://erp.ontruck.io/web/static/src/js/framework/class.js:89:38)

at OdooClass.Class (https://erp.ontruck.io/web/static/src/js/framework/class.js:106:33)

at OdooClass.Widget.extend.add_record (https://erp.ontruck.io/web_kanban/static/src/js/kanban_column.js:141:22)

Here is my entire code for your reference: (your solution starting on line 44)

<?xml version="1.0"?>

<xpath expr="//kanban" position="replace">

<kanban default_group_by="stage_id" class="o_kanban_small_column">

<field name="stage_id" options="{&quot;group_by_tooltip&quot;: {&quot;requirements&quot;: &quot;Description&quot;, &quot;legend_priority&quot;: &quot;Use of stars&quot;}}"/>

<field name="color"/>

<field name="priority"/>

<field name="planned_revenue"/>

<field name="user_email"/>

<field name="user_id"/>

<field name="partner_address_email"/>

<field name="message_needaction_counter"/>

<field name="tag_ids"/>

<field name="partner_id"/>

<field name="active"/>

<field name="company_currency"/>

<field name="x_quote_pickup_city"/>

<field name="x_quote_delivery_city"/>

<field name="x_quote_value"/>

<templates>

<field name="date_deadline"/>

<t t-name="kanban-box">

<div t-attf-class="#{kanban_color(record.color.raw_value)} oe_kanban_global_click">

<div class="o_dropdown_kanban dropdown">

<a class="dropdown-toggle btn" data-toggle="dropdown" href="#">

<span class="fa fa-bars fa-lg"/>

</a>

<ul class="dropdown-menu" role="menu" aria-labelledby="dLabel">

<t t-if="widget.editable"><li><a type="edit">Edit</a></li></t>

<t t-if="widget.deletable"><li><a type="delete">Delete</a></li></t>

<li t-if="! record.active.value"><a name="action_set_active" type="object">Unarchive</a></li>

<li t-if="record.active.value"><a name="action_set_unactive" type="object">Archive</a></li>

<li><ul class="oe_kanban_colorpicker" data-field="color"/></li>

</ul>

</div>

<div class="oe_kanban_content">

<div>

<field name="tag_ids"/>

</div>

<div>

<strong><field name="name"/></strong>

</div>

<div>

<span t-if="x_quote_pickup_city.raw_value and x_quote_delivery_city.raw_value">

<t t-raw="x_quote_pickup_city.raw_value"/> →

<t t-raw="x_quote_delivery_city.raw_value"/>

</span>

</div>

<div class="text-muted">

<t t-if="record.planned_revenue.raw_value"><field name="planned_revenue" widget="monetary" options="{'currency_field': 'company_currency'}"/></t> <span t-if="record.partner_id.value"> - <t t-esc="record.partner_id.value"/></span>

</div>

<div class="text-muted">

<t t-if="record.date_action.raw_value and record.date_action.raw_value lt (new Date())" t-set="red">oe_kanban_text_red</t>

<span t-attf-class="#{red || ''}">

<field name="date_action"/>

<t t-if="record.date_action.raw_value"> : </t>

<field name="next_activity_id"/>

</span>

</div>

<div class="o_kanban_footer">

<field name="priority" widget="priority" groups="base.group_user"/>

<t t-if="record.message_needaction_counter.raw_value">

<span class="oe_kanban_mail_new" title="Unread Messages"><i class="fa fa-comments"/><t t-raw="record.message_needaction_counter.raw_value"/></span>

</t>

<img t-att-src="kanban_image('res.users', 'image_small', record.user_id.raw_value)" t-att-title="record.user_id.value" width="24" height="24" class="oe_kanban_avatar pull-right"/>

</div>

</div>

<div class="oe_clear"/>

</div>

</t>

</templates>

</kanban>

</xpath>

PS this is for the "CRM - Leads Kanban" view.


0
Avatar
Opusti
Enjoying the discussion? Don't just read, join in!

Create an account today to enjoy exclusive features and engage with our awesome community!

Prijavi
Related Posts Odgovori Prikazi Aktivnost
Extending kanban: template t-call not working ? Solved
templates kanban t-call V16
Avatar
1
avg. 24
2239
How to make the order of "default_group_by" in kanban view?
kanban
Avatar
Avatar
1
jan. 25
2786
"harmonised" template for various use cases
templates
Avatar
0
jul. 24
2236
How can i inherit this template? Solved
templates
Avatar
Avatar
1
sep. 23
2771
How to add search bare in a template that allow to search record in a modele ?
templates
Avatar
Avatar
1
jun. 23
3729
Community
  • Tutorials
  • Dokumentacija
  • Forum
Open Source
  • Prenesi
  • Github
  • Runbot
  • Prevodi
Services
  • Odoo.sh Hosting
  • Podpora
  • Nadgradnja
  • Custom Developments
  • Izobraževanje
  • Find an Accountant
  • Find a Partner
  • Become a Partner
About us
  • Our company
  • Sredstva blagovne znamke
  • Kontakt
  • Zaposlitve
  • Dogodki
  • Podcast
  • Blog
  • Stranke
  • Pravno • Zasebnost
  • Varnost
الْعَرَبيّة Català 简体中文 繁體中文 (台灣) Čeština Dansk Nederlands English Suomi Français Deutsch हिंदी Bahasa Indonesia Italiano 日本語 한국어 (KR) Lietuvių kalba Język polski Português (BR) română русский язык Slovenský jazyk slovenščina Español (América Latina) Español ภาษาไทย Türkçe українська Tiếng Việt

Odoo is a suite of open source business apps that cover all your company needs: CRM, eCommerce, accounting, inventory, point of sale, project management, etc.

Odoo's unique value proposition is to be at the same time very easy to use and fully integrated.

Website made with

Odoo Experience on YouTube

1. Use the live chat to ask your questions.
2. The operator answers within a few minutes.

Live support on Youtube
Watch now