تخطي للذهاب إلى المحتوى
القائمة
لقد تم الإبلاغ عن هذا السؤال
1 الرد
5964 أدوات العرض

I have a custom field:
https://i.imgur.com/Bz5e1Vw.png

I'm trying to use it inside a view to display text conditionaly. I added this code inside maintenance request kanban view (marked as <!-- HERE -->):

<?xml version="1.0"?>
<kanban class="oe_background_grey o_kanban_dashboard o_maintenance_team_kanban" create="0">
<field name="name"/>
<field name="color"/>
<field name="see_all"/> <!-- HERE -->
<field name="todo_request_ids"/>
<field name="todo_request_count"/>
<field name="todo_request_count_date"/>
<field name="todo_request_count_high_priority"/>
<field name="todo_request_count_block"/>
<field name="todo_request_count_unscheduled"/>
<templates>
<t t-name="kanban-box">
<div t-attf-class="#{kanban_color(record.color.raw_value)}">
<div t-attf-class="o_kanban_card_header">
<div class="o_kanban_card_header_title">
<div class="o_primary">
<a name="109" type="action">
<field name="name"/>
</a></div>
</div>
<div class="o_kanban_manage_button_section">
<a class="o_kanban_manage_toggle_button" href="#"><i class="fa fa-ellipsis-v" role="img" aria-label="Manage" title="Manage"/></a>
</div>
</div>
<div class="container o_kanban_card_content">
<div class="row">
<div class="col-6 o_kanban_primary_left">
<button class="btn btn-primary" name="109" type="action" context="{'search_default_todo': 1}">
<t t-esc="record.todo_request_count.value"/> To Do
</button>
<!-- HERE -->
<br/>
<div>
<t t-esc="record.see_all"/>
<p t-if="record.see_all.value == 1">When true</p>
<p t-else="">When false</p>
</div>
<!-- -->

And this is the result:
https://i.imgur.com/9C2lug5.png

It displays as object and it is always true (even if the variable is set to false).

Why this does not work?
I edited it with odoo developer UI. How archieve this with custom module? How do I specify where to put my div with xpath?

الصورة الرمزية
إهمال
أفضل إجابة

Hello,

You can  write as following :

<div>
<t t-esc="record.see_all.raw_value"/>
<p t-if="record.see_all.raw_value">When true</p>
<p t-else="">When false</p>
</div>
الصورة الرمزية
إهمال
المنشورات ذات الصلة الردود أدوات العرض النشاط
0
يناير 25
1328
1
مارس 25
652
3
نوفمبر 23
17404
1
سبتمبر 23
2564
3
نوفمبر 24
25081