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

Hi All, 

I have a custom module which exports xlsx accounting reports.  When I export the report, it is saved in /var/lib/odoo directory instead in Downloads folder. Temporarily I set the path to home:

home = os.getenv("HOME")

When I print the home, the result is /var/lib/odoo. How do I get the home directory?


Thanks!

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

try 

from os.path import expanduser
home = expanduser("~")

or if you are in python 3.5 + try

from pathlib import Path
home = str(Path.home())


الصورة الرمزية
إهمال
الكاتب

Hi Hilar,

I've tried both but the output path is still /var/lib/odoo..

المنشورات ذات الصلة الردود أدوات العرض النشاط
1
يوليو 25
2182
3
فبراير 25
15457
1
أبريل 25
2397
Export Import تم الحل
1
أبريل 25
2397
0
أكتوبر 23
1698