Skip ke Konten
Menu
Pertanyaan ini telah diberikan tanda
1 Balas
3328 Tampilan

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.

Avatar
Buang
Jawaban Terbai

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.

Avatar
Buang
Penulis

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.

Post Terkait Replies Tampilan Aktivitas
3
Okt 23
7377
1
Sep 23
2626
1
Mei 23
1600
2
Apr 23
2014
1
Mar 23
1549