It is possible to access the string of the field?
Example:
privacy = fields.Selection([('y', _("Yes")), ('n', _("No"))], string=_("Generic Privacy")
I want "Generic Privacy"
Thanks in advance
Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:
It is possible to access the string of the field?
Example:
privacy = fields.Selection([('y', _("Yes")), ('n', _("No"))], string=_("Generic Privacy")
I want "Generic Privacy"
Thanks in advance
I used the same way to get the field name in qweb pdf reports like this:
style=" margin-inline-end: 20px;">t-esc="doc._fields['movement'].string" />
however when I translated the module the field string value remained in the original language
do you have any idea how can I get the translated string value of a field?
use t-field instead of t-esc, just t-field="doc.field_name"
I don't want the field value I want the field name in this case "string attribute"
Maak vandaag nog een account aan om te profiteren van exclusieve functies en deel uit te maken van onze geweldige community!
Aanmelden| Gerelateerde posts | Antwoorden | Weergaven | Activiteit | |
|---|---|---|---|---|
|
1
dec. 22
|
5495 | |||
|
1
jun. 19
|
5425 | |||
|
0
mrt. 24
|
1505 | |||
|
3
feb. 24
|
5318 | |||
|
1
aug. 22
|
2590 |
1. Use the live chat to ask your questions.
2. The operator answers within a few minutes.
Similar request:
https://www.odoo.com/fr_FR/forum/aide-1/question/how-to-get-string-of-selection-field-148745
Hi,
You will get field string by adding this in your python code
or
Thanks
you can use the string attribute of the field:
field_string = self.env['your.model'].fields_get(['privacy'])['privacy']['string']
In the above code, replace 'your.model' with the actual model name where the privacy field is defined. The fields_get method returns a dictionary of field definitions, and you can access the string value of the privacy field from the dictionary.
Now, the field_string variable will contain the string value "Generic Privacy" as defined in the field declaration.