Search code examples
odooodoo-10odoo-view

Odoo 10 use custom field contents


Probably noob question, but I find it hard to wrap my head around this:

I can create custom field (boolean) on Project model by adding field and modifying the form view:

<field name="x_project_urgent"/>

This works well as expected. Now, I want to render some html based on the value of this field in my kanban view:

where I want to have conditional information enter image description here

The code I would like could read something like this(but obviously this doesn't work):

<div attrs="{'invisible': [('x_project_urgent', '=', True)]}">
  URGENT
</div>

so x_project_urgent is my boolean custom field. If in this 'kanban' view i use <field> tag, it will show the True/False . The thing is I just want to have some simple logic and not just display True/False .

I have no idea how to access project's x_project_urgent custom attribute and write any 'logic' code in the view.

project.x_project_urgent

gives me error: Error: Unknown field project.x_project_urgent in

My guess is that this is possible but I'm such a noob with odoo that I dont even know where to find it in the documentation...


Solution

  • EDITS :

    When i showed the value of the x_project_urgent booelan field in kanban look at the result:

    <div class="o_primary">
        <span><t t-esc="record.name.value"/></span>
        <span t-field="record.x_project_urgent"/>
        <span t-esc="record.x_project_urgent"/>
        <span t-esc="record.x_project_urgent.value"/>
    </div>
    

    enter image description here

    AND this is how you should do it:

    <t t-if="record.x_project_urgent.value">
        <div> URGENT</div>
    </t>
    

    enter image description here