Skip to Content
Menu
This question has been flagged
2 Replies
9221 Views

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?

Avatar
Discard
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

Avatar
Discard
Author 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.


Avatar
Discard
Related Posts Replies Views Activity
1
Aug 24
241
0
Nov 24
68
0
Jul 24
225
1
Sep 23
707
1
Jun 23
1870