跳至内容
菜单
此问题已终结
2 回复
3537 查看

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

形象
丢弃
最佳答案

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.

形象
丢弃
最佳答案

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

形象
丢弃
相关帖文 回复 查看 活动
2
11月 18
5230
2
12月 23
20210
3
4月 23
55467
2
11月 22
3813
1
3月 19
3947