For the needs of a project, I modified the field widgets to process a new attribute that I pass into the field's declration in xml like so:
<field name="name" ... my_attribute=".." />
When the field widget is initialized, it reads the my_attribute in the field's arch and executes a set of actions. The problem is, I need whatever I pass into my_attribute to be translateable, but since, by default, odoo only translates a set of predefined attributes defined in the TRANSLATED_ATTRS variable inside the translate.py file located in the odoo/tools folder as follows:
TRANSLATED_ATTRS = {
'string', 'help', 'sum', 'avg', 'confirm', 'placeholder', 'alt', 'title', 'aria-label',
'aria-keyshortcuts', 'aria-placeholder', 'aria-roledescription', 'aria-valuetext',
'value_label'
}
Now, I can add a key to the variable just fine by doing this in a custom python file:
from odoo.tools.translate import TRANSLATED_ATTRS
TRANSLATED_ATTRS.add('my_attribute')
But to make the translation cleaner, I also need to modify the translate_xml_node function in translate.py so that it only process part of the data provided in my_attribute, and trying to import the function and monkey patching it doesn't seem to work! And I don't really see myself directly modifying the original translate.py file just for a couple lines of code.
Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:
- Müşteri İlişkileri Yönetimi
- e-Commerce
- Muhasebe
- Envanter
- PoS
- Project
- MRP
Bu soru işaretlendi
4209
Görünümler
Enjoying the discussion? Don't just read, join in!
Create an account today to enjoy exclusive features and engage with our awesome community!
Üye Ol| İlgili Gönderiler | Cevaplar | Görünümler | Aktivite | |
|---|---|---|---|---|
|
|
0
Kas 19
|
3883 | ||
|
|
1
Kas 19
|
6729 | ||
|
|
2
Nis 24
|
2239 | ||
|
|
7
Ağu 20
|
36837 | ||
|
|
0
Ara 19
|
3260 |