Skip to Content
Menú
This question has been flagged
1 Respondre
3331 Vistes

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
Descartar
Best Answer

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
Descartar
Autor

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.

Related Posts Respostes Vistes Activitat
3
d’oct. 23
7430
1
de set. 23
2671
1
de maig 23
1608
2
d’abr. 23
2025
1
de març 23
1556