Ir al contenido
Menú
Se marcó esta pregunta
2 Respuestas
3469 Vistas

Hi, 

I'm new to Odoo and I am following the "Getting started" tutorial (sorry, I can't post links yet).

In Chapter 15 there is an example of a Kanban view. I managed to display the values via the field tag and name attribute, but the provided image in the "Goal" note of "Concrete Example: A Kanban View" section, shows that there are static description strings (like: "Expected price: ", or "Best offer: ") near the actual model values. I would like to put them also in my view.

I have read the Kanban view reference in Odoo's documentation, and I noticed that string attribute of field tag is not supported as it is for the tree view, so how can I manage to put the UI description beside the actual value?


Inserting (before the field) a label tag with the description in it will not consider blank spaces, and the " " entity won't work either.


Thanks in advance

Avatar
Descartar
Mejor respuesta

Try using this kind of approach. 

t t-if="record.state.raw_value == 'offer_r'">

​div class="o_kanban_field">

​Best Offer: 

​field name="best_offer">

​/div>

/t>

(I removed the tags because submitting the answer would cause the code to disappear)

Here is the exercise given in 15th chapter. First of all ill explain the o_kanban_field. I used it to separate the fields because they were in the same line and you can write your label straight in the div(If you want to make the text bold surround the text with tag). The t-if is for the best offer to be visible only if the state is offer received.

Avatar
Descartar
Mejor respuesta

Hi,


To add static description strings next to the actual model values in a Kanban view in Odoo, you can achieve this by using the t-field attribute. The t-field attribute is used for defining the string to display in the field on the Kanban card. Here's how you can do it:

Add a t-field attribute to the field tag, and set it to a string that includes the description and a placeholder for the actual field value. For example:

<field name="expected_price" t-field="('Expected price: %s' % record.expected_price)"/>

   


In this example, the string "Expected price: " is displayed along with the actual value of the expected_price field.

<kanban>
    <field name="name"/>
    <field name="expected_price" t-field="('Expected price: %s' % record.expected_price)"/>
    <field name="best_offer" t-field="('Best offer: %s' % record.best_offer)"/>
    <!-- Add more fields with descriptions as needed -->
</kanban>

   



Hope it helps

Avatar
Descartar
Publicaciones relacionadas Respuestas Vistas Actividad
2
nov 18
5193
2
dic 23
20140
3
abr 23
55388
2
nov 22
3761
1
mar 19
3906