تخطي للذهاب إلى المحتوى
القائمة
لقد تم الإبلاغ عن هذا السؤال
1 الرد
2566 أدوات العرض

I have the following python code:

from odoo import api, exceptions, fields, models _
...
def action_confirm(self):
self.ensure_one()

if self.state != 'verified':
raise exceptions.UserError(_("You can only confirm approved records!"))

self.state = 'confirmed'


When I try to export a .po translation file through the Export Translation wizard in Settings -> Translations -> Export Translations, as also specified in the documentation


the python translation does not get exported. Only xml view translations, field names and field help text export. 

Manually adding the python translation works, however it is super annoying and error prone.


This is what I am expecting to see in the .po file but is missing:

#. module: my_module
#. odoo-python
#: code:addons/my-modules-repo/my_module/models/my_model.py:0
#: code:addons/my_module/models/my_model.py:0
#, python-format
msgid "You can only confirm approved records!"
msgstr "Lahko le potrjujete odobrene zapise!"

What do I need to do in order for the translation, defined in a python script _("You can only confirm approved records!"), to show up in the exported .po file?


الصورة الرمزية
إهمال
الكاتب أفضل إجابة

I solved it. The issue was in the odoo.conf file addons_path order.

Before I had:

addons_path = /opt/odoo-odoo17/odoo/addons,
              /opt/odoo-odoo17/enterprise,
              /opt/odoo-odoo17/www,
              /opt/odoo-odoo17/www/my-modules/

then I changed the order to:

addons_path = /opt/odoo-odoo17/odoo/addons,
              /opt/odoo-odoo17/enterprise,
              /opt/odoo-odoo17/www/my-modules/,
              /opt/odoo-odoo17/www

and it exported python translations.

الصورة الرمزية
إهمال

I have the same issue. Is there a way to do this when I have Odoo hosted on Odoo.sh?

المنشورات ذات الصلة الردود أدوات العرض النشاط
4
مايو 25
2270
2
مايو 25
5637
1
مارس 25
1475
4
مارس 25
4253
3
فبراير 25
5240