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

I have created a folder locally in my computer. The invoice value are saved in logging and i want to save same  logging value into a folder available locally. I am able to access the folder and file and also able to create a file but with the empty value in the file. Is it the problem with the sql command or what.

If anyone have any idea plz help me.

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

please try to give user odoo permissions and also access rights to that folder. eg: chown odoo:odoo path and also chmod -R 777 path

Please try this and I am not sure whether this works. If not working then please update your question with more details including test code.

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

The file is created in the path provided but with no value. Even though log file in odoo has several values. I have used following code to create an save value in the file:

@api.model

def archive_and_delete_old_logs(self, nb_days=90, archive_path=''):

if archive_path:

file_name= time.strftime("%Y%m%d_%H%M%S.csv")

file_path= os.path.join(archive_path, file_name)

self.env.cr.execute("""COPY (SELECT * FROM smile_log WHERE log_date + interval '%s days' < NOW() at time zone 'UTC')

TO %s WITH(FORMAT csv, ENCODING utf8)""", (nb_days, file_path,))

self.env.cr.execute("DELETE FROM smile_log WHERE log_date + interval '%s days' < NOW() at time zone 'UTC'",

(nb_days,))

return True

The following model execute by automated action in odoo.

How to save value in the created file.

المنشورات ذات الصلة الردود أدوات العرض النشاط
3
أكتوبر 23
7748
1
سبتمبر 23
2823
1
مايو 23
1793
2
أبريل 23
2323
1
مارس 23
1750