Siirry sisältöön
Menu
Sinun on rekisteröidyttävä, jotta voit olla vuorovaikutuksessa yhteisön kanssa.
Tämä kysymys on merkitty
2 Vastaukset
4102 Näkymät

Hi. I want to start by apologizing for the title, I know it is very confusing, but it is the one that I came up with.

The option text in the dropdown for the custom filter condition from searchview is the same from the "string" attribute in the xml view field definition, NOT from the "string" attribute in the model field definition.

Is there a way to modify the option text?


https://ibb.co/x5NKjKv


I have a model with many fields, including 3 fields to indicate estimates (pessimistic, probable and optimistic) for different values (Date, Rating, Text, ... and many more)


rating_pess = fields.Integer(string='Rating pessimistic')
rating_prob = fields.Integer(string='Rating probable')
rating_opti = fields.Integer(string='Rating optimistic')
text_pess = fields.Char(string='Text pessimistic')
text_prob = fields.Char(string='Text probable')
text_opti = fields.Char(string='Text optimistic')
date_pess = fields.Datetime(string='Date pessimistic')
date_prob = fields.Datetime(string='Date probable')
date_opti = fields.Datetime(string='Date optimistic')
..._pess = fields.---(string='... pessimistic')
..._prob = fields.---(string='... probable')
..._opti = fields.---(string='... optimistic')


In the view, due to the UI requirement, the 3 values for each meassure unit are in different rows using a separator and the label must be "Value" for all the field.


<group col="1">
    <separator string="Text"/>
    <group col="6">
      <field name="text_pess" string="Value"/>
      <field name="text_prob" string="Value"/>
      <field name="text_opti" string="Value"/>
    </group>
    <separator string="Rating"/>
    <group col="6">
      <field name="rating_pess" string="Value"/>
      <field name="rating_prob" string="Value"/>
      <field name="rating_opti" string="Value"/>
    </group>
    <separator string="Date"/>
    <group col="6">
      <field name="date_pess" string="Value"/>
      <field name="date_prob" string="Value"/>
      <field name="date_opti" string="Value"/>
    </group>
    ...
    ...
        
    ...
    ...
</group>


This affects the dropdown control text of the fields in the custom filter, since the source of text of the options seems to be the attribute "string" in the xml view, not the "string" attribute in the field definition in the .py, so then, the text in each option is the same:  "Value", without being able to distinguish the corresponding field (the option "value" attribute in the dropdown is right, 2date_pess", "date_prob", "date_opti").


Thanks!

Avatar
Hylkää

This question is not clear to me. You write "the label must be "Value" for all the field" but then you also write "the text in each option is the same: "Value", without being able to distinguish the corresponding field". My conclusion is that you are making the labels the same and then asking why they are the same?

Paras vastaus

If you are familiar with view customization, you can customize the view and change the values of the string. For example, to change the string value of text_pess you can use the following xpath expression.

<xpath expr="//field[@name='text_pess']" position="attributes">
    <attribute name="string">Pessimistic</attribute>
</xpath>



Avatar
Hylkää
Aiheeseen liittyviä artikkeleita Vastaukset Näkymät Toimenpide
3
maalisk. 15
4358
2
marrask. 18
7858
0
huhtik. 23
2114
2
syysk. 21
4687
3
maalisk. 21
5611